Good way to check for duplicates and remove them from a DataTable, against
a database table?
I have a populated DataTable in my code:
I'm using SQLCE 4.0 and to get around performance issues, I'm using
SQLCEBulkCopy:
SqlCeBulkCopyOptions options = new SqlCeBulkCopyOptions();
options = options |= SqlCeBulkCopyOptions.KeepNulls;
//Check for DB duplicates
using (SqlCeBulkCopy bc = new SqlCeBulkCopy(strConn, options))
{
dt = RemoveDuplicateRows(dt, "Email");
bc.DestinationTableName = "Recipients";
bc.WriteToServer(dt);
}
RemoveDuplicateRows will remove duplicates from the DataTable, but there
is no check against what already exists in the database.
I want to efficiently remove all items in the DataTable that exist in the
actual database table, prior to passing it to WriteToServer(dt).
What would be a good performance , cost effective solution to this problem?
No comments:
Post a Comment