Browse Source

fixed edit transaction

tags/v0.4.0
Robin Thoni 8 years ago
parent
commit
37aac3e5ff
1 changed files with 3 additions and 5 deletions
  1. 3
    5
      Luticate2.Utils/DataAccess/LuEfCrudDataAccess.cs

+ 3
- 5
Luticate2.Utils/DataAccess/LuEfCrudDataAccess.cs View File

396
             {
396
             {
397
                 return GetNotFoundResult<T>();
397
                 return GetNotFoundResult<T>();
398
             }
398
             }
399
-            var transact = BeginTransaction(null);
400
             var editRes = Execute((db, table) =>
399
             var editRes = Execute((db, table) =>
401
             {
400
             {
401
+                var transact = BeginTransaction(db);
402
                 var model = GetEditQueryable(db, table).FirstOrDefault(GetExpression(new KeyValuePair<string, object>("id", guid)));
402
                 var model = GetEditQueryable(db, table).FirstOrDefault(GetExpression(new KeyValuePair<string, object>("id", guid)));
403
                 EditModelFromTUpdate(update, model);
403
                 EditModelFromTUpdate(update, model);
404
                 var res = _EditSingleById(model, update, db, table);
404
                 var res = _EditSingleById(model, update, db, table);
408
                     return res.To<T>();
408
                     return res.To<T>();
409
                 }
409
                 }
410
                 db.SaveChanges();
410
                 db.SaveChanges();
411
+                CommitTransaction(transact);
411
                 return LuResult<T>.Ok(default(T));
412
                 return LuResult<T>.Ok(default(T));
412
             });
413
             });
413
             if (!editRes)
414
             if (!editRes)
414
             {
415
             {
415
-                RollbackTransaction(transact);
416
                 return editRes;
416
                 return editRes;
417
             }
417
             }
418
-            var getRes = GetSingleById(id).To(returnFunc);
419
-            CommitTransaction(transact);
420
-            return getRes;
418
+            return GetSingleById(id).To(returnFunc);
421
         }
419
         }
422
 
420
 
423
         public virtual LuResult<TId> EditSingleByIdId(TId id, TDboUpdate update)
421
         public virtual LuResult<TId> EditSingleByIdId(TId id, TDboUpdate update)

Loading…
Cancel
Save