/// <summary>
 /// Delete Method
 /// </summary>
 /// <param name="entity"></param>
 public void Delete(T entity)
 {
     if (context.Entry(entity).State == EntityState.Detached)
     {
         dbSet.Attach(entity);
     }
     dbSet.Remove(entity);
 }
Exemple #2
0
        public virtual int Update(Expression <Func <TEntity, object> > propertyExpression, bool isSave = true, params TEntity[] entities)
        {
            UnitOfWorkContext.RegisterModified(propertyExpression, entities);
            if (!isSave)
            {
                return(0);
            }
            var dbSet = UnitOfWorkContext.Set <TEntity>();

            dbSet.Local.Clear();
            foreach (var entity in entities)
            {
                UnitOfWorkContext.Entry(entity).State = EntityState.Modified;
            }
            return(UnitOfWorkContext.Commit());
        }