subsonic / SubSonic-3.0

SubSonic 3.0 for the .NET 3.5 Framework
http://subsonic.github.io/
558 stars 210 forks source link

Issue in Left Joins #192

Open mmuekk opened 14 years ago

mmuekk commented 14 years ago

I have tried to execute this query, with latest source code, but with not success

            var maqAll2 = from p in db.Machines
                          join q in db.Projects on p.ProjectID equals q.ProjectID into qq
                          from q in qq.DefaultIfEmpty()
                          select p;

This is the error message that I'm getting:

"Expression of type 'System.Collections.Generic.IEnumerable1[DBProvider.Machine]' cannot be used for parameter of type 'System.Linq.IQueryable1[DBProvider.Machine]' of method 'System.Linq.IQueryable1[<>f__AnonymousType02[DBProvider.Machine,System.Collections.Generic.IEnumerable1[DBProvider.Project]]] GroupJoin[Machine,Project,Nullable1,<>fAnonymousType02](System.Linq.IQueryable1[DBProvider.Machine], System.Collections.Generic.IEnumerable1[DBProvider.Project], System.Linq.Expressions.Expression1[System.Func2[DBProvider.Machine,System.Nullable1[System.Int32]]], System.Linq.Expressions.Expression1[System.Func2[DBProvider.Project,System.Nullable1[System.Int32]]], System.Linq.Expressions.Expression1[System.Func3[DBProvider.Machine,System.Collections.Generic.IEnumerable1[RB.Cfar.Kiosk.DBProvider.Project],<>fAnonymousType02[DBProvider.Machine,System.Collections.Generic.IEnumerable1[DBProvider.Project]]]])'"

jpturski commented 14 years ago

this query have two "Froms"?

a workaround for left joins is the use of subqueryes...

select new { P = p, Q = (from ....).SingleOrDefault() };

mmuekk commented 14 years ago

Hi,

yes I have 2 from, because it required as you can see in this tutorial

http://msdn.microsoft.com/en-us/vcsharp/ee908647.aspx#leftouterjoin

KraftwerkBeard commented 14 years ago

I have exactly the same issue. The syntax used above is standard LINQ syntax for left joins. I have been creating views to do my left joins for me, but having subsonic support left joins would be more maintainable.