SubSonic-3.0
SubSonic-3.0 copied to clipboard
Issue in Left Joins
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.IQueryable
1[DBProvider.Machine]' of method 'System.Linq.IQueryable1[<>f__AnonymousType0
2[DBProvider.Machine,System.Collections.Generic.IEnumerable1[DBProvider.Project]]] GroupJoin[Machine,Project,Nullable
1,<>f__AnonymousType02](System.Linq.IQueryable
1[DBProvider.Machine], System.Collections.Generic.IEnumerable1[DBProvider.Project], System.Linq.Expressions.Expression
1[System.Func2[DBProvider.Machine,System.Nullable
1[System.Int32]]], System.Linq.Expressions.Expression1[System.Func
2[DBProvider.Project,System.Nullable1[System.Int32]]], System.Linq.Expressions.Expression
1[System.Func3[DBProvider.Machine,System.Collections.Generic.IEnumerable
1[RB.Cfar.Kiosk.DBProvider.Project],<>f__AnonymousType02[DBProvider.Machine,System.Collections.Generic.IEnumerable
1[DBProvider.Project]]]])'"
this query have two "Froms"?
a workaround for left joins is the use of subqueryes...
select new { P = p, Q = (from ....).SingleOrDefault() };
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
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.