public static void SaveCustomerTypeGraph(CustomerType customerType) { using (var context = new Model1ContainerContainer()) { context.CustomerTypes.Add(customerType); foreach (var entry in context.ChangeTracker .Entries <IObjectWithState>()) { IObjectWithState stateInfo = entry.Entity; entry.State = ConvertState(stateInfo.State); } context.SaveChanges(); } }
private static void ApplyChanges <TEntity>(TEntity root) where TEntity : class, IObjectWithState { using (var context = new Model1ContainerContainer()) { context.Set <TEntity>().Add(root); // cazul cand o clasa din model nu implementeaza // interfata IObjectWithState CheckForEntitiesWithoutStateInterface(context); foreach (var entry in context.ChangeTracker .Entries <IObjectWithState>()) { IObjectWithState stateInfo = entry.Entity; entry.State = ConvertState(stateInfo.State); } context.SaveChanges(); } }