LEFT JOIN query?

Apr 17, 2009 at 9:47 AM
Edited Apr 19, 2009 at 12:55 PM
Hi all,

As far as I have been able to check, the library does not currently support the "into" LINQ keyword. 

A query that goes something along these lines will compile but fail at runtime:

var query = 
                    from a in db.Master
                    join b in db.Detail on a.CommonField equals b.CommonField into MasterDetail
                    from c in MasterDetail.DefaultIfEmpty()
                    select new 
                        {
                             Field1 = a.Field1,
                             Field2 = c != null? c.Field2 : null,
                        }

throwing an exception with a message similar to this: The expression of type 'System.Linq.IQueryable`1[<>f__AnonymousType4`2[Master,System.Collections.Generic.IEnumerable`1[Detail]]]' is not a sequence.

After going over the code that throws the exception (QueryBinder/ConvertToSequence), it appears that the line - from c in MasterDetail.DefaultIfEmpty() - does not get parsed becouse it is not a projection nor a new expression nor a member access. So, I guess that the "into" keyword is not supported.

Can anybody confirm me whether my understanding of this is correct or know of any possible alternative to do left joins?

Thanks for your help,
Vicente Almagro
Apr 17, 2009 at 10:08 AM
Edited Apr 19, 2009 at 12:56 PM

(Updated above)
PS: the join should add an equality condition:

var query =
from a in db.Master
join b in db.Detail on a.CommonField equals b.CommonField into MasterDetail
from c in MasterDetail.DefaultIfEmpty()
select new
{
Field1 = a.Field1,
Field2 = c != null? c.Field2 : null,
}

De: valmagro [mailto:notifications@codeplex.com]
Enviado el: viernes, 17 de abril de 2009 11:47
Para: valmagro@abalan.com
Asunto: May I have a LEFT JOIN query? [IQToolkit:53627]

 

From: valmagro

Hi all,

As far as I have been able to check, the library does not currently support the "into" LINQ keyword.

A query that goes something along these lines will compile but fail at runtime:

var query =
from a in db.Master
join b in db.Detail into MasterDetail
from c in MasterDetail.DefaultIfEmpty()
select new
{
Field1 = a.Field1,
Field2 = c != null? c.Field2 : null,
}

throwing an exception with a message similar to this: The expression of type 'System.Linq.IQueryable`1[<>f__AnonymousType4`2[Master,System.Collections.Generic.IEnumerable`1[Detail]]]' is not a sequence.

After going over the code that throws the exception (QueryBinder/ConvertToSequence), it appeas that the line - from c in MasterDetail.DefaultIfEmpty() - does not get parsed becouse it is not a projection nor a new expression nor a member access. So, I guess that the "into" keyword is not supported.

Can anybody confirm me whether my understanding of this is correct or know of any possible alternative to do left joins?

Thanks for your help,
Vicente Almagro

Read the full discussion online.

To add a post to this discussion, reply to this email (IQToolkit@discussions.codeplex.com)

To start a new discussion for this project, email IQToolkit@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Coordinator
May 7, 2009 at 12:44 AM
The underlying LINQ 'GroupJoin' operator was not yet supported.  It is now.
May 7, 2009 at 7:41 AM
Edited May 7, 2009 at 7:43 AM
Thanks a lot. This toolkit is great.

Vicente Almagro