BaseDal 中对实体进行软删除

 

public class BaseDal<T> where T:class,new()
{
    public DbContext Db
    {
        get { return DbContextFactory.GetCurrentDbContext(); }
    }

    public bool Delete(T Entity)
    {
        Db.Entry(Entity).Property("DelFlag").CurrentValue = true;
        Db.Entry(Entity).Property("DelFlag").IsModified = true;

        return Db.SaveChanges() > 0;
    }
}

 

posted @ 2018-08-10 15:19  linyongqin  阅读(145)  评论(0编辑  收藏  举报