Welcome to MSDN Blogs Sign in | Join | Help

BenkoBLOG

Find out what's possible with all this new technology stuff...

Syndication

That LINQ Error...

In today's webcast on LINQ in C# we looked at joining XML data with SQL Server and we got the error "Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains() operator" when we tried to run it. Looking deeper into what happened, it appears that the order in which collections are joined in LINQ is important. The original code looked like this:

image

What I found is that we need to specify that we're working with the XML resultset v in venues first and then join to e in events...basically reverse the order that the joined set linqs the two:

image

Weird...

Published Wednesday, January 07, 2009 10:33 PM by benko

Comments

# re: That LINQ Error... @ Wednesday, January 07, 2009 6:14 PM

What's weird about it?  Take a look in Reflector and you'll probably see the root of the matter.  Basically, it's a difference in asking LINQ to SQL to join to an XML result, or LINQ to XML to join to a LINQ to SQL result.

Incidentally, why are you defining var events?  There's neither filtering nor reprojection, so dc.Events would be just fine.

kfarmer

Anonymous comments are disabled
Page view tracker