Linq to DataTable Demo

attribute1_name    attribute2_name
--------------     ---------------

Age                State
Age                weekend_percent
Age                statebreaklaw
Age                Annual Sales
Age                Assortment


var distinctValues = dsValues.AsEnumerable()
                        .Select(row => new {
                            attribute1_name = row.Field<string>("attribute1_name"),
                            attribute2_name = row.Field<string>("attribute2_name")
                         })
                        .Distinct();

 

the datatype of disticntValues  should be 'DataRow[]'

 

 

 

https://stackoverflow.com/questions/3242892/select-distinct-rows-from-datatable-in-linq

posted on 2021-08-12 16:02  yuanxin1991  阅读(22)  评论(0)    收藏  举报

导航