.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

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -