LINQ Join Where Clause

Viewed 97288

I'm struggling with a join/where clause with what is a rather simple sql select statement.

I am trying to retrieve a list of product information from tb1 with the where condition behind situated in tbl2 but this must be joined by three different columns.

so the SQL would look something along the lines of:

SELECT     tb1.*
FROM         tb2 INNER JOIN
                      tb1 ON tb2.Col1 = tb1. Col1 AND tb2.Col2 = tb1. Col2 AND 
                      tb2.Col3 = tb1.Col3
WHERE     (tb2.Col1 = col1) AND (tb2.Col2 = col2) AND (tb2.Col4 = string)

ColX is the main where clause with the string to be passed in as parameter; all other columns are within the contexts.

How do you implement multiple joins with a where clause?

And shoves in the right direction, muchly appreciated.

3 Answers

Also you can group result and use subquery

var innerGroupJoinQuery2 =
    from category in categories
    join prod in products on category.ID equals prod.CategoryID into prodGroup
    from prod2 in prodGroup
    where prod2.UnitPrice > 2.50M
    select prod2;

ref.: join clause (C# Reference)

Related