Sha256: 27596a5eb6cf6eba77c9c12c12a28872657cc3186f72f38f511981ec78f6f373
Contents?: true
Size: 987 Bytes
Versions: 4
Compression:
Stored size: 987 Bytes
Contents
using System; using System.Data; using System.Data.Objects; using System.Linq; namespace Model { /// <summary> /// Extensions to the default container /// </summary> public partial class ModelContainer { partial void OnContextCreated() { SavingChanges += ContainerSavingChanges; } private static void ContainerSavingChanges(object sender, EventArgs e) { var updatedEntites = ((ObjectContext) sender).ObjectStateManager.GetObjectStateEntries(EntityState.Modified); foreach (var ose in updatedEntites) { var type = ose.Entity.GetType(); if (type.GetProperties().Any(p => typeof(AuditFields).IsAssignableFrom(p.PropertyType))) { dynamic entity = ose.Entity; entity.AuditFields.ModifiedDate = DateTime.UtcNow; } } } } }
Version data entries
4 entries across 4 versions & 1 rubygems