public virtual void Update(T entity) { IDbEntityEntryContext entry = _objectContext.GetEntry(entity); if (entry.IsState(EntityState.Detached)) { _objectSet.Attach(entity); } else { entry.SetState(EntityState.Modified); } }
public virtual void Add(T entity) { IDbEntityEntryContext entry = _objectContext.GetEntry(entity); if (entry.IsState(EntityState.Detached)) { _objectSet.Add(entity); } else { entry.SetState(EntityState.Added); } }
public virtual void Remove(T entity) { IDbEntityEntryContext entry = _objectContext.GetEntry(entity); if (entry.IsState(EntityState.Detached)) { _objectSet.Attach(entity); } else { entry.SetState(EntityState.Deleted); } _objectSet.Remove(entity); }