mehdime / DbContextScope

A simple and flexible way to manage your Entity Framework DbContext instances
http://mehdi.me/ambient-dbcontext-in-ef6/
MIT License
631 stars 273 forks source link

Working with Store Procedure and Transaction #59

Open edidiway opened 6 years ago

edidiway commented 6 years ago

Hi, I have issue while working with stored procedure my stored procedure have update command, and after the execution, I tried to retrieve the updated record. my code is like below

using (var dbContextScope = dbContextScopeFactory.CreateWithTransaction(IsolationLevel.Serializable))
{
    var vendorID = "12345";

    //in this function, it will run SP, and inside the SP will update the vendor document status
    result = VendorProvider.spRecalculateVendorDocument(vendorID); 

    //get vendor document
    //vendorDocument object still have old status
    vendorDocument = VendorProvider.GetVendorDocument(vendorID);

    //commit database CRUD
    //after commit the db, vendor document status is updated to new one
    await dbContextScope.SaveChangesAsync();
}

the problem is, the vendorDocument object still hold the old data, although after execute dbContextScope.savechange(). the value in database will be updated to new one.