I have a datatable and a row. I want to import the row to the datatable only if it does not exist in the datatable.
How can i do that?
If you use a typed DataSet
, I.e. declared in design time, the "linq Contains method" takes a typed DataRow
. The default IEqualityComparer
will compare all values in the DataRow
. (Which is normally useless, since you should have a key defined).
DataSet1 ds = new DataSet1();
DataSet1.DataTable1Row row = ds.DataTable1.AddDataTable1Row(bla, bla);
bool exists = ds.DataTable1.Contains(row);