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

Document transaction support #26

Closed
MikaelEliasson opened this issue Dec 20, 2014 · 6 comments
Closed

Document transaction support #26

MikaelEliasson opened this issue Dec 20, 2014 · 6 comments

Comments

@MikaelEliasson
Copy link
Owner

The current batch operation DOES support transactions by using TransactionScope. Document this.

@dahrnsbrak
Copy link
Contributor

Can you give a brief explanation of this? I've done context.Database.BeginTransaction around my call to InsertAll, but it doesn't seem to work.

@MikaelEliasson
Copy link
Owner Author

Check this code.From one of my projects.

image

@MikaelEliasson
Copy link
Owner Author

A bit more code than you need and DB.Use is a replacement for using(var db = new DbContext()). TransactionScope is the key here.

MikaelEliasson added a commit that referenced this issue May 14, 2015
@MikaelEliasson
Copy link
Owner Author

Fixed

@Gabriel-Espinoza
Copy link

Please leave more documentation about this. It's really unusable.

@thetalkingtree
Copy link

Just use
using (var ts = new TransactionScope())
{
using (DbEntities ctx = new DbEntities())
{
EFBatchOperation.For(ctx, ctx.YourEntity).InsertAll(list);
ctx.SaveChanges();
}
ts.Complete();
}

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

No branches or pull requests

4 participants