using EntrustSettle.Model; using SqlSugar; using System; using System.Collections.Generic; using System.Data; using System.Linq.Expressions; using System.Threading.Tasks; namespace EntrustSettle.IServices.Base { /// /// /// /// 已在中注册,可以直接在需要的地方注入 public interface IBaseServices where TEntity : class, new() { ISqlSugarClient Db { get; } #region 查询 ISugarQueryable AsQueryable(); Task QueryById(object objId); Task QueryById(object objId, bool blnUseCache = false); Task> QueryByIDs(object[] lstIds); Task QueryFirst(Expression> whereExpression); Task QueryFirst(Expression> whereExpression, Expression> selectExpression); Task QueryFirstInclude(Expression> whereExpression, Expression>> include); Task> Query(); Task> Query(Expression> whereExpression); Task> Query(Expression> whereExpression, Expression> selectExpression); Task> Query(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true); Task> Query(Expression> whereExpression, string orderByFields); Task> Query(string where, string orderByFields); Task> QueryTop(string where, int intTop, string orderByFields); Task> QueryTop(Expression> whereExpression, int intTop, string orderByFields); Task> QueryPage(string where, int pageIndex, int pageSize, string orderByFields); Task> QueryPage(Expression> whereExpression, int pageIndex, int pageSize, string orderByFields); Task> QueryPageModel(Expression> whereExpression, int pageIndex = 1, int pageSize = 20, Expression> orderByExpression = null, bool isAsc = true); Task> QueryPageModel(Expression> whereExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null); Task> QueryPageModel(Expression> whereExpression, PaginationModel paginationModel); Task> QuerySql(string sql, SugarParameter[] parameters = null); Task QueryTable(string sql, SugarParameter[] parameters = null); #endregion #region 新增 IInsertable AsInsertable(TEntity model); IInsertable AsInsertable(List listEntity); Task Add(TEntity model); Task> Add(List listEntity); #endregion #region 删除 Task Delete(Expression> whereExpression); Task DeleteById(object id); Task Delete(TEntity model); Task DeleteByIds(object[] ids); #endregion #region 更新 IUpdateable AsUpdateable(); IUpdateable AsUpdateable(TEntity model); IUpdateable AsUpdateable(params TEntity[] entities); Task Update(TEntity model); Task Update(TEntity entity, Expression> updateColumns); Task Update(List model); Task Update(TEntity entity, string where); Task Update(TEntity entity, List lstColumns = null, List lstIgnoreColumns = null, string where = ""); Task Update(Expression> columns, Expression> where); #endregion #region Split分表基础接口 (基础CRUD) /// /// 通过ID查询(自动分表) /// Task QueryByIdSplit(object objId); /// /// 分页查询(自动分表) /// Task> QueryPageSplit(Expression> whereExpression, DateTime beginTime, DateTime endTime, int pageIndex = 1, int pageSize = 20, string orderByFields = null); /// /// 插入(自动分表) /// Task> AddSplit(TEntity entity); /// /// 删除(自动分表) /// Task DeleteSplit(TEntity entity, DateTime dateTime); /// /// 更新(自动分表) /// Task UpdateSplit(TEntity entity, DateTime dateTime); #endregion } }