Reputation: 3128
I am using the EF4 code first for db access. I needed to wrap some changes in a transaction and change the isolation level to repeatable read. It would be a cinch to write this in SQL, but EF is giving me a hard time. Is there any way to accomplish this?
Upvotes: 1
Views: 951
Reputation: 364369
You must use TransactionScope
:
using (var scope = new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions { IsolationLevel = IsolationLevel.RepetableRead} ))
{
// Grab data
// Process changes
context.SaveChanges();
scope.Complete();
}
Upvotes: 2