Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static bool Update<U>(U dContext, int iCurrentUserId)
- where U : DbContext
- {
- using (var tx = dContext.Database.BeginTransaction())
- {
- try
- {
- foreach (T tItem in dContext.Set<T>())
- {
- if (dContext.Entry(tItem).State != EntityState.Modified) continue;
- ModificationSet(tItem, iCurrentUserId);
- }
- dContext.SaveChanges();
- tx.Commit();
- return true;
- }
- catch (Exception e)
- {
- tx.Rollback();
- return false;
- }
- }
- }
- foreach (T tItem in dContext.Set<T>().Where(z => dContext.Entry(z).State == EntityState.Modified))
- foreach (T tItem in dContext.ChangeTracker.Entries<T>().Where(z => z.State == EntityState.Modified).Select(z => z.Entity))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement