The class “PaginatedReport” has two members :
int TotalResults;
IList<Report> Reports;
I try to populate an instance of this class using this query :
var reports = (from r in _db.Report
where r.res_id == status
group r by r.res_id into g
select new PaginatedReport
{
TotalResults = g.Count(),
Reports = g.OrderBy(x =>x.res_id).Skip(start).Take(nb).ToList()
});
How can I correct the query to avoid the following error :
Linq to entitites do not recognize the method “System.Collections.Generic.List1[DAL.Report]1[DAL.Report])”, and this method cannot be translated into a store.
ToList[Report](System.Collections.Generic.IEnumerable
You need to perform the last step (a
Selectreturning an anonymous type) locally, rather than having the LINQ provider try and translate it into (presumably) SQL. Something like:(and you don’t need parentheses around the whole expression).