using Admin.Core.Model; using SqlSugar; using System; using System.Collections.Generic; using System.Data; using System.Linq.Expressions; using System.Threading.Tasks; namespace Admin.Core.IRepository { public interface IBaseRepository where TEntity : class { /// /// SqlsugarClient实体 /// ISqlSugarClient Db { get; } /// /// 根据Id查询实体 /// /// /// Task QueryByIdAsync(object objId); Task QueryByIdAsync(object objId, bool blnUseCache = false); /// /// 根据id数组查询实体list /// /// /// Task> QueryByIDsAsync(object[] lstIds); /// /// 添加 /// /// /// Task AddAsync(TEntity model); /// /// 批量添加 /// /// /// Task AddAsync(List listEntity); /// /// 根据id 删除某一实体 /// /// /// Task DeleteByIdAsync(object id); /// /// 根据对象,删除某一实体 /// /// /// Task DeleteAsync(TEntity model); /// /// 根据id数组,删除实体list /// /// /// Task DeletesAsync(List entitys); /// /// 更新model /// /// /// Task UpdateAsync(TEntity model); /// /// 根据model,更新,带where条件 /// /// /// /// Task UpdateAsync(TEntity entity, string strWhere); Task UpdateAsync(object operateAnonymousObjects); /// /// 根据model,更新,指定列 /// /// /// /// /// /// Task UpdateAsync(TEntity entity, List lstColumns = null, List lstIgnoreColumns = null, string strWhere = ""); /// /// 正序查询第一条数据 /// /// Task FirstAsync(); /// /// 根据条件查询查询第一条数据 /// /// /// Task FirstAsync(Expression> whereExpression); /// /// 查询 /// /// Task> QueryAsync(); /// /// 带sql where查询 /// /// /// Task> QueryAsync(string strWhere); /// /// 根据表达式查询 /// /// /// Task> QueryAsync(Expression> whereExpression); /// /// 根据表达式,指定返回对象模型,查询 /// /// /// /// Task> QueryAsync(Expression> expression); /// /// 根据表达式,指定返回对象模型,排序,查询 /// /// /// /// /// /// Task> QueryAsync(Expression> expression, Expression> whereExpression, string strOrderByFileds); Task> QueryAsync(Expression> whereExpression, string strOrderByFileds); Task> QueryAsync(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true); Task> QueryAsync(string strWhere, string strOrderByFileds); Task> QueryAsync(Expression> whereExpression, int intTop, string strOrderByFileds); Task> QueryAsync(string strWhere, int intTop, string strOrderByFileds); Task> QuerySqlAsync(string strSql, SugarParameter[] parameters = null); Task ExecSqlAsync(string strSql, SugarParameter[] parameters = null); Task QueryTableAsync(string strSql, SugarParameter[] parameters = null); Task> QueryAsync( Expression> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds); Task> QueryAsync(string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds); /// /// 根据表达式,排序字段,分页查询 /// /// /// /// /// /// Task> QueryPageAsync(Expression> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null); /// /// 三表联查 /// /// /// /// /// /// /// /// /// Task> QueryMuchAsync( Expression> joinExpression, Expression> selectExpression, Expression> whereLambda = null) where T : class, new(); /// /// 两表联查-分页 /// /// /// /// /// /// /// /// /// /// /// Task> QueryTabsPageAsync( Expression> joinExpression, Expression> selectExpression, Expression> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null); /// /// 两表联合查询-分页-分组 /// /// /// /// /// /// /// /// /// /// /// /// Task> QueryTabsPageAsync( Expression> joinExpression, Expression> selectExpression, Expression> whereExpression, Expression> groupExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null); #region 同步 /// /// 根据Id查询实体 /// /// /// TEntity QueryById(object objId); TEntity QueryById(object objId, bool blnUseCache = false); /// /// 根据id数组查询实体list /// /// /// List QueryByIDs(object[] lstIds); /// /// 添加 /// /// /// Task Add(TEntity model); /// /// 批量添加 /// /// /// int Add(List listEntity); /// /// 根据id 删除某一实体 /// /// /// bool DeleteById(object id); /// /// 根据对象,删除某一实体 /// /// /// bool Delete(TEntity model); /// /// 根据id数组,删除实体list /// /// /// bool Deletes(List entitys); /// /// 更新model /// /// /// bool Update(TEntity model); /// /// 根据model,更新,带where条件 /// /// /// /// bool Update(TEntity entity, string strWhere); bool Update(object operateAnonymousObjects); /// /// 根据model,更新,指定列 /// /// /// /// /// /// bool Update(TEntity entity, List lstColumns = null, List lstIgnoreColumns = null, string strWhere = ""); /// /// 查询 /// /// List Query(); /// /// 带sql where查询 /// /// /// List Query(string strWhere); /// /// 根据表达式查询 /// /// /// List Query(Expression> whereExpression); /// /// 根据表达式,指定返回对象模型,查询 /// /// /// /// List Query(Expression> expression); /// /// 根据表达式,指定返回对象模型,排序,查询 /// /// /// /// /// /// List Query(Expression> expression, Expression> whereExpression, string strOrderByFileds); List Query(Expression> whereExpression, string strOrderByFileds); List Query(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true); List Query(string strWhere, string strOrderByFileds); List Query(Expression> whereExpression, int intTop, string strOrderByFileds); List Query(string strWhere, int intTop, string strOrderByFileds); List QuerySql(string strSql, SugarParameter[] parameters = null); int ExecSql(string strSql, SugarParameter[] parameters = null); DataTable QueryTable(string strSql, SugarParameter[] parameters = null); List Query( Expression> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds); List Query(string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds); /// /// 根据表达式,排序字段,分页查询 /// /// /// /// /// /// PageModel QueryPage(Expression> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null); /// /// 三表联查 /// /// /// /// /// /// /// /// /// List QueryMuch( Expression> joinExpression, Expression> selectExpression, Expression> whereLambda = null) where T : class, new (); /// /// 两表联查-分页 /// /// /// /// /// /// /// /// /// /// /// PageModel QueryTabsPage( Expression> joinExpression, Expression> selectExpression, Expression> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null); /// /// 两表联合查询-分页-分组 /// /// /// /// /// /// /// /// /// /// /// /// PageModel QueryTabsPage( Expression> joinExpression, Expression> selectExpression, Expression> whereExpression, Expression> groupExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null); #endregion } }