【发布时间】:2012-07-26 00:58:08
【问题描述】:
我的 Linq to Entity 查询有问题。我试图返回这样的列表:
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);
但它给了我错误:
无法投射类型>'System.Data.Objects.ObjectQuery
1[LicExpiryNotModel_EF41.Model.InvoiceReportItem]' to > type 'System.Collections.Generic.List1[LicExpiryNotModel_EF41.Model.InvoiceReportItem]'的对象。
有谁知道为什么会出现这个错误?快把我逼疯! :(
提前致谢 尼尔
【问题讨论】:
-
不要投,只是把
.ToList()放在查询后面。
标签: c# linq frameworks entity