0
我有以下查询如何将匿名类型转换为实体框架?
var db = new Entities();
IQueryable<Tbl_RSCRegularSupply> qrySupp = (from cont in db.Tbl_RSC
where cont.ID == contractID
let RegSupp = new
{
RegSupply = from R in cont.Tbl_RSCSupplyPlan
select R.Tbl_RSCRegularSupply
}
select (Tbl_RSCRegularSupply)RegSupp.RegSupply);
return qrySupp.AsParallel().ToList();
但是只能执行这个创建以下例外。
无法强制类型'System.Collections.Generic.IEnumerable`1'键入'Tbl_RSCRegularSupply'。 LINQ to Entities仅支持投射实体数据模型基元类型。
这是从上面的查询中获得List<Tbl_RSCRegularSupply>
的一些好方法。
它并没有解决问题。我同意你,它返回的东西就像那个IEnumerable>但它如何可能得到列表 –
Shamim
2012-04-25 05:06:58
'Selectmany'应该这样做......? (后跟ToList())。 – 2012-04-25 06:43:28