如何使用entity-framework从表中获取不同的行。
就像我想要的那样,2个不同的行名称是唯一的:
1| 04-DEC-15| 01-JAN-01 |4 |1 |10000.0 |0.0 |ship |None |LP_Joc1_B1 |01-JAN-01| 0
6| 28-DEC-15 | 01-JAN-01 |4 |1 |30000.0 |0.0 |ship |None |LP_Joc1_B2 |01-JAN-01| 0
答案 0 :(得分:1)
//distinct based on a specific property (in this case Name)
List<Objects> listObjects = (from obj in db.Objects
select obj).GroupBy(n => new {n.Name})
.Select(g => g.FirstOrDefault())
.ToList();