Linq to SQL and Intersect

People,

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

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

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

Thanks in advance.

+3
source share
2 answers

It is definitely possible. See this example:

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

+2
source

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);
+2
source

Source: https://habr.com/ru/post/1769634/


All Articles