I have a problem with my Linq to Entity query.. Im trying to return a list like so:
List<InvoiceReportItem> cancelResults = (List<InvoiceReportItem>)(from cr in model.InvoiceReportItems
//join l in model.tblLicences on cr.LicenceAuto equals l.LicenceAuto
where cr.Report.Id == id
select cr);
but its giving me the error:
Unable to cast object of type >’System.Data.Objects.ObjectQuery
1[LicExpiryNotModel_EF41.Model.InvoiceReportItem]' to > type 'System.Collections.Generic.List1[LicExpiryNotModel_EF41.Model.InvoiceReportItem]’.
Does anyone have any idea why its giving this error? driving me crazy! 🙁
Thanks in advance
Neil
Use ToList()