Closed rajkamal0610 closed 2 months ago
Hello @rajkamal0610 ,
Here is an online example how to use a transaction with the bulk operation library: https://dotnetfiddle.net/rFpG6G
var transaction = connection.BeginTransaction();
customers = GenerateCustomers(5);
// SAVE customers
using (var bulk = new BulkOperation<Customer>(connection))
{
bulk.Transaction = transaction;
bulk.DestinationTableName = "Customers";
bulk.BulkMerge(customers);
}
transaction.Commit();
The Throwing error like cannot access disposed object
is often associated when using an async method wrongly. The connection/transaction is already disposed before the code in the async method is executed. I'm not sure if that is currently your case as some code is missing for it.
Let me know if that answers your question correctly. If you need more assistance, please provide more code or an online example like mine.
Best Regards,
Jon
Thanks for your quick response. Will update you with code sample
Hello @rajkamal0610,
Since our last conversation, we haven't heard from you.
Let me know if you need further assistance.
Best regards,
Jon
Thanks for the support. Code working fine
I need sample code of how to use
**Begin transaction
Commit
Rollback**
While using bulkoperation insert/merge
I try below way
**Bulk.transaction = conn.begintransaction
Conn.transaction.commit ** The code above is not working for me. Throwing error like cannot access disposed object