using jiajie.Model; using SqlSugar; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; namespace jiajie.Repository { public interface IBaseRepository where TEntity : class { /// /// SqlsugarClient实体 /// ISqlSugarClient Db { get; } /// /// 实体集合 /// ISugarQueryable Entities { get; } /// /// 原生 Ado 对象 /// IAdo Ado { get; } IBaseRepository ChangeRepository() where NewEntity : class, new(); /// /// 获取总数 /// /// /// Task CountAsync(Expression> whereExpression); /// /// 检查是否存在 /// /// /// Task AnyAsync(Expression> whereExpression); /// /// 获取一个实体 /// /// /// Task SingleAsync(Expression> whereExpression); /// /// 获取一个实体 /// /// /// Task SingleByIdAsync(object objId); /// /// 获取一个实体 /// /// /// Task FirstOrDefaultAsync(Expression> whereExpression); /// /// 获取一个实体 主键 /// /// /// Task FirstOrDefaultByIdAsync(object id); /// /// 检查存在 /// /// /// Task IsExistsByIdAsync(object id); /// /// 检查存在 /// /// /// Task IsExistsAsync(Expression> whereExpression); /// /// 新增一条记录 /// /// /// Task InsertAsync(TEntity entity); /// /// 新增多条记录 /// /// /// Task InsertAsync(params TEntity[] entities); /// /// 新增多条记录 /// /// /// Task InsertAsync(IEnumerable entities); /// /// 新增一条记录返回自增Id /// /// /// Task InsertReturnIdentityAsync(TEntity entity); /// /// 更新一条记录 /// /// /// Task UpdateAsync(TEntity entity); /// /// 无主键更新一条记录 /// /// 更新的实体 /// 根据那些字段更新 /// Task UpdateNoPrimaryKeyAsync(TEntity entity, Expression> columns); /// /// 无主键更新多条记录 /// /// 更新的实体 /// 根据那些字段更新 /// Task UpdateNoPrimaryKeyAsync(List entitys, Expression> columns); /// /// 更新多条记录 /// /// /// Task UpdateAsync(params TEntity[] entities); /// /// 更新多条记录 /// /// /// Task UpdateAsync(IEnumerable entities); /// /// 删除一条记录 /// /// /// Task DeleteAsync(TEntity entity); /// /// 删除一条记录 /// /// /// Task DeleteAsync(object key); /// /// 删除多条记录 /// /// /// Task DeleteAsync(params object[] keys); /// /// 自定义条件删除记录 /// /// /// Task DeleteAsync(Expression> whereExpression); /// /// 通过主键查询 /// /// /// Task> QueryByIDsAsync(object[] lstIds); /// /// 获取列表 /// /// Task> QueryAsync(); /// /// 获取列表 /// /// /// Task> QueryAsync(Expression> whereExpression); /// /// 获取列表 带排序 /// /// /// /// Task> QueryAsync(Expression> whereExpression, string orderByFields); /// /// 获取列表 带排序 /// /// /// /// /// Task> QueryAsync(Expression> whereExpression, Expression> orderByExpression = null, OrderByType orderByType = OrderByType.Asc); /// /// 查询数据列表 带条件 /// /// 条件 /// 数据列表 Task> QueryAsync(string where); /// /// 查询数据列表 带条件 带排序 /// /// /// /// Task> QueryAsync(string where, string orderByFields); /// /// 查询数据列表 返回指定列 /// /// /// /// Task> QueryAsync(Expression> expression); /// /// 查询数据列表 返回指定列 带条件 带排序 /// /// /// /// /// /// Task> QueryAsync(Expression> expression, Expression> whereExpression, string orderByFields); /// /// 根据sql语句查询 /// /// 完整的sql语句 /// 参数 /// 泛型集合 Task> QuerySqlAsync(string sql, SugarParameter[] parameters = null); /// /// 分页查询数据列表 /// /// /// /// /// /// Task> QueryAsync( Expression> whereExpression, int pageIndex, int pageSize, string orderByFields); /// /// 分页查询数据列表 /// /// /// /// /// /// Task> QueryAsync( string where, int pageIndex, int pageSize, string orderByFields); /// /// 分页查询数据列表 /// /// /// /// /// /// Task> QueryPageAsync( Expression> whereExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null ); /// ///查询-多表查询 /// /// 实体1 /// 实体2 /// 实体3 /// 返回对象 /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} /// 查询表达式 (w1, w2) =>w1.UserNo == "") /// Task> QueryMuch( Expression> joinExpression, Expression> selectExpression, Expression> whereLambda = null) where T : class, new(); /// /// 两表联合查询-分页 /// /// 实体1 /// 实体1 /// 返回对象 /// 关联表达式 /// 返回表达式 /// 查询表达式 /// 页码 /// 页大小 /// 排序字段 /// Task> QueryTabsPage( Expression> joinExpression, Expression> selectExpression, Expression> whereExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null); /// /// 两表联合查询-分页-分组 /// /// 实体1 /// 实体1 /// 返回对象 /// 关联表达式 /// 返回表达式 /// 查询表达式 /// group表达式 /// 页码 /// 页大小 /// 排序字段 /// Task> QueryTabsPage( Expression> joinExpression, Expression> selectExpression, Expression> whereExpression, Expression> groupExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null); } }