public static void ApplyStateChanges(this DbContext context) { foreach (var entity in context.ChangeTracker.Entries <IObjectsWithState>()) { IObjectsWithState stateInfo = entity.Entity; entity.State = StateHelpers.ConvertState(stateInfo.State); } }
public static void ApplyStateChanges(this IContext context) { foreach (var entry in (context as DbContext).ChangeTracker.Entries <IAudit>()) { IAudit stateInfo = entry.Entity; entry.State = StateHelpers.ConvertState(stateInfo.State); } }
public void InsertOrUpdate(Products products) { if (products.Id == default(int)) { context.Entry(products).State = EntityState.Added; } else { context.Products.Add(products); context.Entry(products).State = StateHelpers.ConvertState(products.State); } }