本文介绍了LINQ to DataSet,以多列分隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只想检查是否有办法按多列进行区分.预先谢谢!!!

Just wanted to check if there is way to do distinct by multiple columns. Thanks in advance!!!

顺便说一句,我发现了一个很棒的LINQ扩展,但需要一些指导才能将其用于多列

BTW, I found a great LINQ extension here but need some guidance to use it for multiple columns

推荐答案

好吧,您可以先进行投影:

Well, you can do the projection first:

var qry = db.Customers.Select(cust => new {cust.ID, cust.Name, cust.Region})
                    .Distinct();

或使用查询语法:

var qry = (from cust in db.Customers
          select new {cust.ID, cust.Name, cust.Region}).Distinct();

那样吗?

这篇关于LINQ to DataSet,以多列分隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-15 08:02