.net - DataTable.AsEnumerable().Distinct() doesn't work because of primary key column -


I want to remove the duplicate from my DataTable , so I DataTable.AsEnumerable ( ) .Distinct (DataRowComparer.Default) But what I do not think it is necessary for me is because this is the unique primary key column in each duplicate line.

What can I do according to my requirement? Write your own DataRowComparer ? I do not want to - because the default should work.

You can use from project basically to launch those data from a data line into those columns For example, which you are interested in, and it will use it for example:

  var rows = datatable.assenameremable (). Undoubtedly (line = & gt; new {name = line ["name"], age = line ["age"]});  

When you say "the default should work", if it is not originally, if you have a normal primary key column with two different primary key values, not two rows are duplicates of each other, because they are different in that data.

Another option would be to project data rows without the primary key column, and then use the normal specific method.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -