C# DataTable get unique records using LINQ. Hi. . I have a DataTable I need to get the unique records. The table has over 25 fields. The first argument in the above method tells that we want distinct rows. public DataTable ToTable(bool distinct, params string[ columnNames) Select all Open in new window.Apr 23, 2015 now i have source data in. net datatable and need to filter in the above way. column names) does not work as distinct is applied for all the columns. Subodh, In SQL Server, the distinct in your SQL query is applied to all c# datatable linq distinct
get distinct rows from datatable using Linq (distinct with mulitiple columns) Or try this. var distinctRows (from DataRow dRow in dTable. Rows select new EDIT: Placed the
Not the answer you're looking for? Browse other questions tagged c# linq or ask your own question. Oct 27, 2010 Home ASP. NET Forums Data Access ADO. NET, Entity Framework, LINQ to SQL, NHibernate How to get the distinct value form DataTable using LINQ? How to get the distinct value form DataTable using LINQ? c# datatable linq distinct How do I get a distinct, ordered list of names from a DataTable using LINQ? Ask Question 92. 3. Browse other questions tagged c# linq. net3. 5 or ask your own question. asked. 10 years, 7 months ago. viewed. 23, 903 times get distinct rows from datatable using Linq (distinct with mulitiple columns) 16.
Sep 06, 2013 I have a datatable with some columns. I need the datatable to return the list as below. Select col1, distinct count(col2) from table1 group by col1. list of col1 and count of values of col2. Please let me know how to do this. Thanks in advance. c# datatable linq distinct 17 Answers. first parameter in ToTable() is a boolean which indicates whether you want distinct rows or not. second parameter in the ToTable() is the column name based on which we have to select distinct rows. Only these columns will be in the returned datatable. The same can be done from a DataSet, by accessing a specific DataTable: How to get a distinct, ordered list of names from a DataTable using LINQ The project illustrates how to get a distinct, ordered list of names from a DataTable using LINQ. C# DataTable DISTINCT DataTable Linq DataView ToTable Get Distinct String List From DataTable. Just curious if it's possible to convert a DataTable into a string list and only get the distinct values in one line. May not be possible. Simply move Distinct () before ToList (). FYI, Distinct is an extension method of IEnumerable, not a method of List.Rating: 4.87 / Views: 724