c# - Building linq query that collect records by group -
scenario simple handling in linq require more exp have.. there 3 table
table1 id column 1 val1 2 val2 table2 id column 1 val3 2 val4 table3 id column 1 val5 2 val6
i need such query returns;
tableresult:
row id column type 1 1 val1 table1 2 2 val2 table1 3 1 val3 table2 4 2 val4 table2 5 1 val5 table3 6 2 val6 table3
searched on net , started below cant figure how handle tricks create "type", merge records etc..
t1 in table1 join t2 in table2 on t1.id equals t2.id join t3 in table3 on t1.id equals t3.id select new {...}
same did try distinct @ end. query syntax :
var list = (from t1 in dbcontext.table1 join t2 in dbcontext.table2 on t1.id equals t2.id join t3 in dbcontext.table3 on t1.id equals t3.id select new { //t1.desiredcolumnname, //t2.desiredcolumnname, //t3.desiredcolumnname, //so on }).distinct().tolist();
Comments
Post a Comment