linqlinq-to-sqlormsubsonic3

LINQ to Subsonic Left Outer Join


I have the following query:

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:"")};

when I type:

var items = q.ToList();

I got the following exception:

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]]]])'

Any idea?

Note: content_item.All() is IQueryable and vendor.All() is IQueryable


Solution

  • Sorry I missed this question back when you asked it...

    The left outer join syntax in SubSonic 3 is slightly different. I have a workaround posted as an answer to this question: Subsonic 3.0 Left Join