【发布时间】:2011-11-16 00:12:58
【问题描述】:
我必须将 string 值转换为 int,但似乎 LINQ to Entities 不支持这一点。
对于以下代码,我遇到了错误。
var query = (from p in dc.CustomerBranch
where p.ID == Convert.ToInt32(id) // here is the error.
select new Location()
{
Name = p.BranchName,
Address = p.Address,
Postcode = p.Postcode,
City = p.City,
Telephone = p.Telephone
}).First();
return query;
LINQ to Entities 无法识别方法“
Int32 ToInt32 (System.String)”,并且该方法无法转换为存储表达式。
【问题讨论】:
标签: entity-framework linq-to-entities