我需要把一个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)
',此方法无法转换为存储表达式。