/// <summary> /// Inserts a new entity on the database. /// </summary> /// <param name="entity">The entity object.</param> public void Insert(TEntity entity) { if (ChangeTrackerEnabled) { var graph = new FWEntityGraph(Context); graph.TrackChange(entity); } _dbSet.Add(entity); }
/// <summary> /// Updates an entity. /// </summary> /// <param name="entity">The entity object.</param> public void Update(TEntity entity) { if (ChangeTrackerEnabled) { var graph = new FWEntityGraph(Context); graph.TrackChange(entity); } _dbSet.Attach(entity); Context.Entry(entity).State = EntityState.Modified; }
/// <summary> /// Removes an entity from the database. /// </summary> /// <param name="entity">The entity object.</param> public virtual void Delete(TEntity entity) { if (Context.Entry(entity).State == EntityState.Detached) { _dbSet.Attach(entity); } _dbSet.Remove(entity); if (ChangeTrackerEnabled) { var graph = new FWEntityGraph(Context); graph.TrackDelete(entity); } }