You can split the query in two to make sure the list is in memory before calling the GetNumberOfDevices() method. You can query in memory by converting the results to List or in this case a List<GetFreeDevices> . Thus, LinQ to Entities does not need to translate from and from XML, and you can use your GetNumberOfDevices() method.
var view_query = (from i in query select new GetFreeDevices { MArticleNumber = i.ArticleNumber, MFirmware = i.Firmware, MGroup = i.Group, MName = i.Name, MSoftware = i.SoftwareVersion }).ToList(); var result_query = from i in query select new GetFreeDevices { MArticleNumber = i.MArticleNumber, MFirmware = i.MFirmware, MGroup = i.MGroup, MName = i.MName, MSoftware = i.MSoftware, SA = GetNumberOfDevices(i.MArticleNumber,2), STH = GetNumberOfDevices(i.MArticleNumber,3), SASTH = GetNumberOfDevices(i.MArticleNumber,7) }; return PartialView(result_query);
Note that the last statement requires that PartialView accept a list or IEnumerable instead of IQueryable .
Prutswonder
source share