SHARE
TWEET

Untitled

a guest Jun 20th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public async Task<int> SaveChangesAsync(string userName, string impersonatorId)
  2.     {
  3.         try
  4.         {
  5.             AddMetadataToEntity(userName, impersonatorId);
  6.             var audit = new Audit();
  7.  
  8.             audit.CreatedBy = impersonatorId != null ? impersonatorId : userName;
  9.  
  10.             audit.PreSaveChanges(this);
  11.             int rowAffected = await base.SaveChangesAsync().ConfigureAwait(false);
  12.             audit.PostSaveChanges();
  13.  
  14.             if (audit.Configuration.AutoSavePreAction != null)
  15.             {
  16.                 audit.Configuration.AutoSavePreAction(this, audit);
  17.                 await base.SaveChangesAsync().ConfigureAwait(false);
  18.             }
  19.  
  20.             return rowAffected;
  21.         }
  22.         catch (DbUpdateConcurrencyException ex)
  23.         {
  24.             foreach (EntityEntry entry in ex.Entries)
  25.             {
  26.                 System.Diagnostics.Debug.WriteLine(entry.GetType().Name);
  27.                 foreach (Microsoft.EntityFrameworkCore.Metadata.IProperty prop in entry.CurrentValues.Properties)
  28.                 {
  29.                     System.Diagnostics.Debug.WriteLine("t" + prop.Name);
  30.                     System.Diagnostics.Debug.WriteLine("t" + entry.CurrentValues[prop]);
  31.                 }
  32.             }
  33.             throw ex;
  34.         }
  35.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top