Linq查询里面没有工作调用方法
我的linq示例查询:
public class CrewItem
{
public string LastName { get; set; }
public List<AddressItem> Addresses { get; set; }
}
public CrewItem GetCrewForDetail(Guid id, string language)
{
var query = (from p in _DbEntities.t_Crew
where p.c_ID.Equals(id)
select new CrewItem
{
LastName = p.c_LastName,
Addresses = GetAddressForCrew(p.c_ID),
}).AsEnumerable();
}
public List<AddressItem> GetAddressForCrew(Guid id)
{
var query = from p in _DbEntities.t_CrewAddress
where p.ca_cID.Equals(id)
select p;
if (query.Count() > 0)
{
foreach (var item in query)
{
_Addresses.Add(new AddressItem
{
C_ID = item.ca_cID,
Ca_ID = item.ca_ID,
Address = item.ca_Address,
BusinessPhone = item.ca_BusinessPhone,
City = item.ca_City,
Country = item.ca_Country,
HomePhone = item.ca_HomePhone,
Mail = item.ca_Mail,
MobilePhone = item.ca_MobilePhone,
SecondMail = item.ca_SecondMail,
Town = item.ca_Town,
});
}
}
return _Addresses;
}
错误:
> base {System.Exception} = {"LINQ to Entities does not recognize the method
'System.Collections.Generic.List`1[CrewNetixData.Entity.Defination.AddressItem]
GetAddressForCrew(System.Guid)' method, and this method cannot be translated into a
store expression."}