Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Join in LINQ and Entity Framework

In SQL I to get the distinct statement, I used join to get it as below

select distinct 
    col1 
from 
    table1 a 
inner join 
    table2 b on a.code = b.vcode

How can the same be implemented in LINQ over Entity Framework?

Please suggest me.

like image 715
user1893874 Avatar asked Nov 04 '15 14:11

user1893874


1 Answers

You can also use method syntax:

var query = table1.Join(table2,
                        a => a.code,
                        b => b.vcode,
                        (a,b) => a.col1)
                   .Distinct();
like image 102
w.b Avatar answered Sep 18 '22 15:09

w.b