我使用下面的代码编译没有问题,但是当我打电话的方法,我得到这个错误:LINQ错误:方法无法识别
LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.
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();
}
怎样才可以重新编写,以便上班?
什么是城市属性的类型? – StriplingWarrior