Пример #1
0
        void UpdateTimeStamps(SaveOptions saveOptions)
        {
            var ignore  = saveOptions.ExcludeTimestamps;
            var entries = ChangeTracker.Entries <ITimestamp>();

            foreach (var entry in entries)
            {
                if (ignore?.Any(x => x == entry.Entity) == true)
                {
                    continue;
                }

                if (entry.State == EntityState.Added)
                {
                    entry.Entity.DateCreated = DateTime.UtcNow;
                }

                if (entry.State == EntityState.Added || entry.State == EntityState.Modified)
                {
                    entry.Entity.LastUpdated = DateTime.UtcNow;
                }
            }
        }
Пример #2
0
 public Task <int> SaveChangesAsync(SaveOptions options)
 {
     UpdateContext(options);
     return(base.SaveChangesAsync());
 }
Пример #3
0
 public int SaveChanges(SaveOptions options)
 {
     UpdateContext(options);
     return(base.SaveChanges());
 }