Sk Asraf Sk Asraf - 5 months ago 13
SQL Question

What is the exact LINQ Query for this SQL Query?

I can't understand what the exact

Linq
query is of this SQLquery.

Please give exact
Linq
Query similar to this SQL query.

Select * From tblProduct
Where ProductId In
(Select ProductId from tblViewer Where ViewerId = 123)

Answer

Contains is the most straightforwrad way to implement an IN statement, so it would be something like:

tblProduct.Where(p => tblViewer.Where(v => v.ViewerId == 123)
                               .Select(v => v.ProductId)
                               .Contains(p.ProductId)
                );