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