public bool PersistDelta(List <IdentifiedObject> inserted, List <IdentifiedObject> updatedNew, List <IdentifiedObject> deleted, Dictionary <DMSType, int> newCounters) { try { using (DBContext context = new DBContext()) { for (int i = 0; i < inserted.Count; ++i) { IdentifiedObject io = inserted[i]; IEFTable table = tables[(int)ModelCodeHelper.GetTypeFromGID(io.GID)]; object entity = io.ToDBEntity(); table.Insert(context, entity); } for (int i = 0; i < updatedNew.Count; ++i) { IdentifiedObject io = updatedNew[i]; IEFTable table = tables[(int)ModelCodeHelper.GetTypeFromGID(io.GID)]; object entity = io.ToDBEntity(); table.Update(context, entity); } for (int i = 0; i < deleted.Count; ++i) { IdentifiedObject io = deleted[i]; IEFTable table = tables[(int)ModelCodeHelper.GetTypeFromGID(io.GID)]; object entity = io.ToDBEntity(); table.Delete(context, entity); } foreach (KeyValuePair <DMSType, int> pair in newCounters) { IEFTable table = tables[0]; ModelCounterDBModel oldCounter = (ModelCounterDBModel)table.Get(context, pair.Key); if (oldCounter != null) { oldCounter.Counter = pair.Value; } else { table.Insert(context, new ModelCounterDBModel() { Type = pair.Key, Counter = pair.Value }); } } context.SaveChanges(); } } catch (Exception e) { return(false); } return(true); }