3

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.

CubanX
  • 5,176
  • 2
  • 29
  • 44

2 Answers2

2

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
  • 71,784
  • 24
  • 131
  • 181
0

var example = memoryObject.Union(sqlObject)is not allowed but you can do var example = sqlOjbect.Union(memoryObject) if both sqlObject and memoryObject are of the same type.

fantagons
  • 9
  • 3