【发布时间】:2011-09-02 13:39:26
【问题描述】:
我使用以下代码编译没有问题,但是当我调用该方法时出现此错误:
LINQ to Entities 无法识别方法“System.String ToString()”方法,并且该方法无法转换为存储表达式。
public IEnumerable<string> GetAllCitiesOfCountry(int id)
{
var ad = from a in entities.Addresses
where a.CountryID == id
select a.City.Distinct().ToString();
var fa = from b in entities.FacilityAddresses
where b.CountryID == id
select b.City.Distinct().ToString();
return ad.Concat(fa).Distinct();
}
如何重写才能工作?
【问题讨论】:
-
City属性的类型是什么?
标签: c# .net linq linq-to-entities