I have a populated DataTable in my code:
I'm using SQL Server CE 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?