如何提高以下 linq 查询的性能?
在运行它时,它抛出了一个错误System.OutOfMemoryException
。
注意:我在实体中有很多记录XrmContext.sun_POSSet
var a = (from temple in XrmContext.sun_POSSet
select new POS()
{
id = temple.Id,
Country = temple.sun_sun_country_sun_POS == null ? "" : temple.sun_sun_country_sun_POS.sun_name,
CountryId = temple.sun_sun_country_sun_POS == null ? "" : temple.sun_sun_country_sun_POS.Id.ToString(),
stringint = temple.sun_sun_stringint_sun_placeofstu == null ? "" : temple.sun_sun_stringint_sun_placeofstu.sun_name,
stringintId = temple.sun_sun_stringint_sun_placeofstu == null ? "" : temple.sun_sun_stringint_sun_placeofstu.Id.ToString(),
FullName = temple.sun_contact_sun_POS.FullName,
EMail = temple.sun_contact_sun_POS.EMailAddress1,
MobilePhone = temple.sun_contact_sun_POS.MobilePhone
}).ToList<POS>();