Join句
Join
01
02
03
04
05
06
07
08
|
var query = dataSet1.table1 .Join(dataSet1.table2, x => x.ID, y => y.ID, (x, y) => new { data= x, value= y.value1, }); |
左結合
01
02
03
04
05
06
07
08
|
var query1 = dataSet1.Table1 .GroupJoin(dataSet1.Table2, x => x.ID, y => y.ID, (x, y) => new { id = x.ID, value = y.Select(z => z.Value1).FirstOrDefault() }); |
Group句
01
02
03
04
05
|
var groupTable1 = dataSet1.table1 .GroupBy(x => x.column1); var groupTable2 = dataSet1.table1 .GroupBy(x => new { x.column1, x.column2 }); |
Count, Sum
01
02
03
04
|
var groupTable = table1 .GroupBy(x => x.category) .Select(x => new { category = x.Key, cout = x.Count(), sum = x.Sum(y => y.price) }); |