May 20, 2014

Linq distinct multiple columns

var qry = db.Customers.Select(cust => new {cust.ID, cust.Name, cust.Region})
                    .Distinct();
Or in query syntax:
var qry = (from cust in db.Customers
          select new {cust.ID, cust.Name, cust.Region}).Distinct();

0 comments:

Post a Comment

Nam Le © 2014 - Designed by Templateism.com, Distributed By Templatelib