【发布时间】:2012-03-05 23:40:14
【问题描述】:
我有以下疑问:
var q = from x in content_item.All()
join y in vendor.All() on x.Vendor_ID equals y.Vendor_ID into tmp
from v in tmp.DefaultIfEmpty()
select new { Z=x.Content_Item_Name,W=((v!=null)?v.Vendor_Name:"")};
当我输入时:
var items = q.ToList();
我遇到了以下异常:
Expression of type 'System.Collections.Generic.IEnumerable`1[Vamp.Models.content_item]' cannot be used for parameter of type 'System.Linq.IQueryable`1[Vamp.Models.content_item]' of method 'System.Linq.IQueryable`1[<>f__AnonymousType0`2[Vamp.Models.content_item,System.Collections.Generic.IEnumerable`1[Vamp.Models.vendor]]] GroupJoin[content_item,vendor,Nullable`1,<>f__AnonymousType0`2](System.Linq.IQueryable`1[Vamp.Models.content_item], System.Collections.Generic.IEnumerable`1[Vamp.Models.vendor], System.Linq.Expressions.Expression`1[System.Func`2[Vamp.Models.content_item,System.Nullable`1[System.UInt32]]], System.Linq.Expressions.Expression`1[System.Func`2[Vamp.Models.vendor,System.Nullable`1[System.UInt32]]], System.Linq.Expressions.Expression`1[System.Func`3[Vamp.Models.content_item,System.Collections.Generic.IEnumerable`1[Vamp.Models.vendor],<>f__AnonymousType0`2[Vamp.Models.content_item,System.Collections.Generic.IEnumerable`1[Vamp.Models.vendor]]]])'
有什么想法吗?
注意:content_item.All() 是 IQueryable 并且 vendor.All() 是 IQueryable
【问题讨论】:
标签: linq linq-to-sql orm subsonic3