i am using a CustomDataRowEqualityComparer()
to compare 2 datatables with different number of columns but they share some columns:
var result= maindatatable.AsEnumerable().Except(dt.AsEnumerable(), new CustomDataRowEqualityComparer()).CopyToDataTable();
how can i make the result datatable contain only the columns in dt
?, in the aboVe contex the
result datatable have the columns of the maindatatable
Here is my comparer class
public class CustomDataRowEqualityComparer : IEqualityComparer<DataRow>
{
public bool Equals(DataRow x, DataRow y)
{
return ((int)x["id"] == (int)y["id"]);
}
public int GetHashCode(DataRow obj)
{
return ((int)obj["id"]);
}
}
it returns all rows in maindatatable
that doesnt exist in dt