SubSonic-3.0 icon indicating copy to clipboard operation
SubSonic-3.0 copied to clipboard

Issue in Left Joins

Open mmuekk opened this issue 14 years ago • 3 comments

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,<>f__AnonymousType02](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],<>f__AnonymousType02[DBProvider.Machine,System.Collections.Generic.IEnumerable1[DBProvider.Project]]]])'"

mmuekk avatar Mar 31 '10 22:03 mmuekk

this query have two "Froms"?

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

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

jpturski avatar Apr 11 '10 16:04 jpturski

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

mmuekk avatar Apr 11 '10 20:04 mmuekk

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.

KraftwerkBeard avatar Apr 19 '10 01:04 KraftwerkBeard