using Microsoft.Data.SqlClient; 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 WIDESEAWCS_Core.BaseRepository { public interface IRepository : IDependency where TEntity : class, new() { /// /// SqlsugarClient实体 /// ISqlSugarClient Db { get; } /// /// 通过主键查询数据 /// /// 主键 /// 查询结果 TEntity QureyDataById(object id); Task QureyDataByIdAsync(object id); /// /// 通过主键数组查询数据 /// /// 主键数组 /// 查询结果集合 List QureyDataByIds(object[] lstIds); Task> QureyDataByIdsAsync(object[] lstIds); /// /// 通过主键集合查询数据 /// /// 主键集合 /// 查询结果集合 List QureyDataByIds(List lstIds); Task> QureyDataByIdsAsync(List lstIds); /// /// 添加单条数据 /// /// /// 影响行数 int AddData(TEntity entity); Task AddDataAsync(TEntity entity); /// /// 添加多条数据 /// /// /// 影响行数 int AddData(List listEntity); Task AddDataAsync(List listEntity); /// /// 通过主键删除数据 /// /// 主键 /// 删除结果 bool DeleteDataById(object id); Task DeleteDataByIdAsync(object id); /// /// 通过主键数据删除多条数据 /// /// 主键数组 /// 删除结果 bool DeleteDataByIds(object[] ids); Task DeleteDataByIdsAsync(object[] ids); /// /// 通过实体数据删除数据 /// /// 主键数组 /// 删除结果 bool DeleteData(TEntity entity); Task DeleteDataAsync(TEntity entity); /// /// 通过实体集合数据删除数据 /// /// 主键数组 /// 删除结果 bool DeleteData(List listEntity); Task DeleteDataAsync(List listEntity); /// /// 更新单条数据 /// /// /// bool UpdateData(TEntity entity); Task UpdateDataAsync(TEntity entity); /// /// 更新多条数据 /// /// /// bool UpdateData(List listEntity); Task UpdateDataAsync(List listEntity); /// /// 指定列更新数据 /// /// /// /// /// bool UpdateData(TEntity entity, List lstColumns, List? lstIgnoreColumns = null); Task UpdateDataAsync(TEntity entity, List lstColumns, List? lstIgnoreColumns = null); /// /// 查询所有数据 /// /// List QueryData(); Task> QueryDataAsync(); /// /// 条件查询数据 /// /// /// List QueryData(string where); Task> QueryDataAsync(string where); /// /// 条件查询数据 /// /// /// List QueryData(Expression> whereExpression); Task> QueryDataAsync(Expression> whereExpression); TEntity QueryFirst(Expression> whereExpression); Task QueryFirstAsync(Expression> whereExpression); TResult QueryFirst(Expression> whereExpression, Expression> expression); Task QueryFirstAsync(Expression> whereExpression, Expression> expression); TResult QueryFirst(Expression> whereExpression, Expression> expression, Dictionary orderBy); Task QueryFirstAsync(Expression> whereExpression, Expression> expression, Dictionary orderBy); TEntity QueryFirst(Expression> whereExpression, Dictionary orderBy); Task QueryFirstAsync(Expression> whereExpression, Dictionary orderBy); /// /// 条件查询数据并排序 /// /// /// /// List QueryData(Expression> whereExpression, Dictionary orderBy); Task> QueryDataAsync(Expression> whereExpression, string orderByFields); /// /// 条件查询数据并排序 /// /// /// /// List QueryData(string where, Dictionary orderBy); Task> QueryDataAsync(string where, Dictionary orderBy); /// /// 查询指定数据对象 /// /// /// /// List QueryData(Expression> expression); Task> QueryDataAsync(Expression> expression); /// /// 条件查询指定数据对象 /// /// /// /// /// /// List QueryData(Expression> expression, Expression> whereExpression, string orderByFields = ""); Task> QueryDataAsync(Expression> expression, Expression> whereExpression, string orderByFields); /// /// 条件查询数据并排序 /// /// /// /// /// List QueryData(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true); Task> QueryDataAsync(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true); /// /// 条件查询数据并排序 /// /// /// /// List QueryData(string where, string orderByFields); Task> QueryDataAsync(string where, string orderByFields); /// /// 原生Sql语句查询数据 /// /// /// /// List QueryDataBySql(string sql, SugarParameter[]? parameters = null); Task> QueryDataBySqlAsync(string sql, SugarParameter[]? parameters = null); /// /// 原生Sql语句查询数据 /// /// /// /// List QueryDynamicDataBySql(string sql, SugarParameter[]? parameters = null); Task> QueryDynamicDataBySqlAsync(string sql, SugarParameter[]? parameters = null); List QueryObjectDataBySql(string sql, SugarParameter[]? parameters = null); Task> QueryObjectDataBySqlAsync(string sql, SugarParameter[]? parameters = null); /// /// 原生Sql语句执行操作 /// /// /// /// int ExecuteSqlCommand(string sql, params SqlParameter[] sqlParameters); Task ExecuteSqlCommandAsync(string sql, params SqlParameter[] sqlParameters); /// /// 原生Sql语句查询数据 /// /// /// /// DataTable QueryTable(string sql, SugarParameter[]? parameters = null); Task QueryTableAsync(string sql, SugarParameter[]? parameters = null); /// /// 条件查询数据指定数量的行 /// /// /// /// /// List QueryData(Expression> whereExpression, int top, string orderByFields); Task> QueryDataAsync(Expression> whereExpression, int top, string orderByFields); /// /// 条件查询指定数量的行 /// /// /// /// /// List QueryData(string where, int top, string orderByFields); Task> QueryDataAsync(string where, int top, string orderByFields); /// /// 分页查询 /// /// /// /// /// /// List QueryData(Expression> whereExpression, int pageIndex, int pageSize, string orderByFields); Task> QueryDataAsync(Expression> whereExpression, int pageIndex, int pageSize, string orderByFields); /// /// 分页查询 /// /// /// /// /// /// List QueryData(string where, int pageIndex, int pageSize, string orderByFields); Task> QueryDataAsync(string where, int pageIndex, int pageSize, string orderByFields); /// /// 分页查询 /// /// /// /// /// /// PageGridData QueryPage(Expression> whereExpression, int pageIndex, int pageSize, string? orderByFields = null); /// /// 分页查询 /// /// /// /// /// /// PageGridData QueryPage(Expression> whereExpression, int pageIndex, int pagesize, Dictionary orderBy); PageGridData QueryPage(string where, int pageIndex, int pageSize, Dictionary orderBy); /// /// 两表联查 /// /// /// /// /// /// /// /// List QueryTabs( Expression> joinExpression, Expression> selectExpression, Expression> whereExpressionT1, Expression> whereExpression); Task> QueryTabsAsync( Expression> joinExpression, Expression> selectExpression, Expression> whereExpression); /// /// 两表联查-分页 /// /// /// /// /// /// /// /// /// /// /// PageGridData QueryTabsPage( Expression> joinExpression, Expression> selectExpression, Expression> whereExpression, int pageIndex = 1, int pageSize = 20, string? orderByFields = null); /// /// 两表联合查询-分页-分组 /// /// /// /// /// /// /// /// /// /// /// /// PageGridData QueryTabsPage( Expression> joinExpression, Expression> selectExpression, Expression> whereExpression, Expression> groupExpression, int pageIndex = 1, int pageSize = 20, string? orderByFields = null); //List QueryMuch( // Expression> joinExpression, // Expression> selectExpression, // Expression> whereLambda = null) where T : class, new(); //Task> QueryPage(PaginationModel pagination); } }