Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BulkMerge inside transaction #3

Closed
mikhail-khalizev opened this issue Jan 13, 2017 · 2 comments
Closed

BulkMerge inside transaction #3

mikhail-khalizev opened this issue Jan 13, 2017 · 2 comments
Assignees

Comments

@mikhail-khalizev
Copy link

mikhail-khalizev commented Jan 13, 2017

Hello.

In my case I need using BulkMegre method inside our transaction. Example source code:

using (var cnn = new SqlConnection("..."))
{
	cnn.Open();
	using (var tran = cnn.BeginTransaction())
	{
		cnn.BulkMerge(entities);
	}
}

But BulkMerge throw exception: ex.txt
Can you help?

@JonathanMagnan JonathanMagnan self-assigned this Jan 13, 2017
@JonathanMagnan
Copy link
Member

JonathanMagnan commented Jan 13, 2017

Thank you,

The issue happens because of the transaction. We will fix this issue today or over the weekend.

Meanwhile, you can use TransactionScope.

See: https://msdn.microsoft.com/en-us/library/system.transactions.transactionscope(v=vs.110).aspx

Best Regards,

Jonathan

@JonathanMagnan
Copy link
Member

Hello @Micky53 ,

The v1.0.12 has been released.

We added extension methods to IDbTransaction.

You can now use the following code:

using (var cnn = new SqlConnection("..."))
{
	cnn.Open();
	using (var tran = cnn.BeginTransaction())
	{
		tran.BulkMerge(entities);
	}
}

It seemed more logic to add an extension method to the transaction instead of adding multiple overloads or a method specific to set the transaction. Let me know if this solution satisfies your requirement or you would like to have a better solution.

Best Regards,

Jonathan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants