Hi All,
Good day.
I have this code:-
using (TransactionScope trans = new TransactionScope())
{
using (SqlConnection conn = new SqlConnection(_Productrepository.Database.GetDbConnection().ConnectionString))
{
bulk.Setup<Product>(x => x.ForCollection(pd))
.WithTable("Products")
.WithBulkCopyCommandTimeout(0) // Default is 600 seconds
.WithBulkCopyBatchSize(50000) // Default is 0 - single batch
.WithBulkCopyEnableStreaming(true)
.WithSqlBulkCopyOptions(SqlBulkCopyOptions.TableLock)
.AddAllColumns()
.CustomColumnMapping(x => x.UniqueId, "UniqueID")
.BulkInsertOrUpdate()
.SetIdentityColumn(x => x.RequisitionID)
.MatchTargetOn(x => x.UniqueId);
bulk.CommitTransaction(conn);
}
trans.Complete();
}
However, it still showing duplicate record with the same UniqueID existed more than once. I want top update existing record if the UniqueID already existed in the existing table.
Can someone help me on this?
Thanks.
Regards,
Micheale