views:

34

answers:

2

Folks,

I need to use Intersect on a LINQ to SQL query. However, I get an exception basically stating that I can't.

The code compiles fine, but LINQ to SQL gets angry.

Is there any way to replicate Intersect with LINQ to SQL?

Thanks in advance.

A: 

It is definitely possible. See this example:

http://msdn.microsoft.com/en-us/library/bb399392.aspx

Adrian Grigore
A: 

Here is an example of how to do this:

var coolColors = (from pen in mydb.Pens select pen.Color).Intersect
        (from pencil in mydb.Pencils select pencil.Color);
Michael Goldshteyn