BaseBll.cs
using PT.DAL; using PT.Model; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PT.BLL { public class BaseBll<T, V> where T : class, new() where V : class, new() { BaseDal<T, V> baseDal = new DAL.BaseDal<T, V>(); #region 查询 /// <summary> /// 查询表所有数据 /// </summary> /// <returns></returns> public virtual List<T> Queryable() { return baseDal.Queryable(); } /// <summary> /// 查询表未删除数据 /// </summary> /// <returns></returns> public virtual List<T> QueryableNotDeleted() { return baseDal.QueryableNotDeleted(); } /// <summary> /// 查询表未删除数据 按条件查询 /// </summary> /// <param name="t"></param> /// <returns></returns> public virtual List<T> QueryableNotDeleted(T t) { return baseDal.QueryableNotDeleted(t); } /// <summary> /// 单主键查询 /// </summary> /// <param name="Id"></param> /// <returns></returns> public virtual T QueryableInSingle(string Id) { return baseDal.QueryableInSingle(Id); } /// <summary> /// 查询单条 没有返回Null,如果结果大于1条会抛出错误 (根据业务重写) /// </summary> /// <param name="t"></param> /// <returns></returns> public virtual UserList QueryableSingle(UserList t) { return baseDal.QueryableSingle(t); } /// <summary> /// 是否存在记录 /// </summary> /// <param name="t"></param> /// <returns></returns> public virtual bool IsExist(T t) { return baseDal.IsExist(t); } #endregion #region 插入 /// <summary> /// 插入 忽略null列 /// </summary> /// <param name="t"></param> /// <returns>返回自增id</returns> public virtual int InsertableIgnoreColumns(T t) { return baseDal.InsertableIgnoreColumns(new List<T>() { t }); } /// <summary> /// 插入 忽略null列 批量 /// </summary> /// <param name="ts"></param> /// <returns></returns> public virtual int InsertableIgnoreColumns(List<T> ts) { return baseDal.InsertableIgnoreColumns(ts); } #endregion #region 更新 /// <summary> /// 更新 /// </summary> /// <param name="t"></param> /// <returns></returns> public virtual int Updateable(T t) { return baseDal.Updateable(t); } /// <summary> /// 更新 根据主键 忽略null列 /// </summary> /// <param name="t"></param> /// <returns></returns> public virtual int UpdateableIgnoreColumns(T t) { return baseDal.UpdateableIgnoreColumns(new List<T>() { t }); } /// <summary> /// 更新 忽略null列 批量 /// </summary> /// <param name="ts"></param> /// <returns></returns> public virtual int UpdateableIgnoreColumns(List<T> ts) { return baseDal.UpdateableIgnoreColumns(ts); } /// <summary> /// 更新 根据自定义条件 忽略null列 (根据业务重写) /// </summary> /// <param name="t"></param> /// <returns></returns> public virtual int UpdateableIgnoreColumnsWhere(T t) { return baseDal.UpdateableIgnoreColumnsWhere(t); } /// <summary> /// 主键等于默认值插入否则更新 id=0插入 id不等于0更新 批量 /// </summary> /// <param name="list"></param> /// <returns>返回影响行数</returns> public virtual int InsertableDefaultAddElseUpdate(List<T> list) { return baseDal.InsertableDefaultAddElseUpdate(list); } /// <summary> /// 主键等于默认值插入否则更新 id=0插入 id不等于0更新 单个 /// </summary> /// <param name="t"></param> /// <returns>返回影响行数</returns> public virtual int InsertableDefaultAddElseUpdate(T t) { return baseDal.InsertableDefaultAddElseUpdate(new List<T>() { t }); } #endregion #region 删除 /// <summary> /// 删除 /// </summary> /// <param name="t"></param> /// <returns></returns> public virtual int Deleteable(T t) { return baseDal.Deleteable(t); } /// <summary> /// 逻辑删除 /// </summary> /// <param name="ModifyBy">修改人</param> /// <param name="Ids">删除id集合</param> /// <returns></returns> public virtual int DeleteableLogic(string ModifyBy, List<int> Ids) { return baseDal.DeleteableLogic(ModifyBy, Ids); } #endregion #region 业务查询,根据业务需要重写方法 /// <summary> /// 视图 多表联查 查询表未删除数据 (根据业务重写) /// </summary> /// <returns></returns> public virtual List<UserListV> QueryableNotDeletedV() { return baseDal.QueryableNotDeletedV(); } /// <summary> /// 视图 多表联查 查询表未删除数据 按条件查询 (根据业务重写) /// </summary> /// <param name="v"></param> /// <returns></returns> public virtual List<IPListV> QueryableNotDeletedV(IPListV v) { return baseDal.QueryableNotDeletedV(v); } /// <summary> /// 视图 多表联查 分页查询 查询表未删除数据 按条件查询 (根据业务重写) /// </summary> /// <param name="where"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="totalCount"></param> /// <returns></returns> public virtual List<IPListV> QueryablePageList(IPListV where, int pageIndex, int pageSize, out int totalCount) { return baseDal.QueryablePageList(where, pageIndex, pageSize, out totalCount); } #endregion } }