1.以一个字段为主键去重的话,直接distinct
SELECT DISTINCT Company FROM Orders
2.以两个字段去重的话,可以这样实现
SELECT Company,Person FROM Orders Group by conmpany ,person
3.如果是想查询多个字段,并且以两个字段为主键的话,可以先生成list,然后在list里面用linq语句以两个字段去重,赋值给一个新的list
IList<PM_SMT_RECEIPE_DETAIL> ReDeList_Some = new List<PM_SMT_RECEIPE_DETAIL>();
ReDeList_Some = ReDeList_All.Where(p => p.Slot == detail.Slot && p.MaterialID == detail.MaterialID).ToList();
如果大家有什么更好的方法,欢迎大家在下面评论!