You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
7.3 KiB
C#

using EntrustSettle.Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace EntrustSettle.IRepository.Base
{
public interface IBaseRepository<TEntity> where TEntity : class
{
/// <summary>
/// SqlsugarClient实体
/// </summary>
9 months ago
ISqlSugarClient Db { get; }
#region 查询
Task<TEntity> QueryById(object objId);
Task<TEntity> QueryById(object objId, bool blnUseCache = false);
Task<List<TEntity>> QueryByIDs(object[] lstIds);
9 months ago
Task<TEntity> QueryFirst(Expression<Func<TEntity, bool>> whereExpression);
Task<TEntity> QueryFirstInclude<TReturn>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, List<TReturn>>> include);
Task<List<TEntity>> Query();
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string orderByFields);
Task<List<TEntity>> Query(string where, string orderByFields);
Task<List<TEntity>> QueryTop(string where, int intTop, string orderByFields);
Task<List<TEntity>> QueryTop(Expression<Func<TEntity, bool>> whereExpression, int intTop, string orderByFields);
Task<List<TEntity>> QueryPage(string where, int pageIndex, int pageSize, string orderByFields);
Task<List<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int pageIndex, int pageSize, string orderByFields);
Task<PageModel<TEntity>> QueryPageModel(Expression<Func<TEntity, bool>> whereExpression, int pageIndex = 1, int pageSize = 20, Expression<Func<TEntity, object>> orderByExpression = null, bool isAsc = true);
Task<PageModel<TEntity>> QueryPageModel(Expression<Func<TEntity, bool>> whereExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null);
Task<List<TResult>> QueryDto<TResult>(Expression<Func<TEntity, TResult>> expression);
Task<List<TResult>> QueryDto<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string orderByFields);
Task<List<TEntity>> QuerySql(string sql, SugarParameter[] parameters = null);
Task<DataTable> QueryTable(string sql, SugarParameter[] parameters = null);
/// <summary>
9 months ago
/// 两表联查
/// </summary>
9 months ago
Task<List<TResult>> QueryMuch<T, T2, TResult>(Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, bool>> whereLambda,
Expression<Func<T, T2, TResult>> selectExpression) where T : class, new();
/// <summary>
9 months ago
/// 两表联查-分页
/// </summary>
9 months ago
Task<PageModel<TResult>> QueryMuchPage<T, T2, TResult>(Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, bool>> whereExpression,
Expression<Func<T, T2, TResult>> selectExpression,
int pageIndex = 1,
int pageSize = 20,
string strOrderByFileds = null);
/// <summary>
9 months ago
/// 两表联合查询-分页-分组
/// </summary>
9 months ago
Task<PageModel<TResult>> QueryMuchPageGroup<T, T2, TResult>(Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, bool>> whereExpression,
Expression<Func<T, T2, TResult>> selectExpression,
Expression<Func<T, object>> groupExpression,
int pageIndex = 1,
int pageSize = 20,
string strOrderByFileds = null);
/// <summary>
9 months ago
/// 三表联查
/// </summary>
9 months ago
Task<List<TResult>> QueryMuch<T, T2, T3, TResult>(Expression<Func<T, T2, T3, object[]>> joinExpression,
Expression<Func<T, T2, T3, bool>> whereLambda,
Expression<Func<T, T2, T3, TResult>> selectExpression) where T : class, new();
/// <summary>
9 months ago
/// 三表联查-分页
/// </summary>
9 months ago
Task<PageModel<TResult>> QueryMuchPage<T, T2, T3, TResult>(Expression<Func<T, T2, T3, object[]>> joinExpression,
Expression<Func<T, T2, T3, bool>> whereExpression,
Expression<Func<T, T2, T3, TResult>> selectExpression,
int pageIndex = 1,
int pageSize = 20,
string strOrderByFileds = null);
#endregion
9 months ago
#region 新增
Task<long> Add(TEntity model);
Task<List<long>> Add(List<TEntity> listEntity);
#endregion
9 months ago
#region 删除
Task<bool> Delete(Expression<Func<TEntity, bool>> whereExpression);
9 months ago
Task<bool> DeleteById(object id);
Task<bool> Delete(TEntity model);
Task<bool> DeleteByIds(object[] ids);
#endregion
9 months ago
#region 更新
Task<bool> Update(TEntity model);
Task<bool> Update(TEntity entity, Expression<Func<TEntity, object>> updateColumns);
Task<bool> Update(List<TEntity> model);
Task<bool> Update(TEntity entity, string where);
Task<bool> Update(object operateAnonymousObjects);
Task<bool> Update(TEntity entity, List<string> lstColumns = null, List<string> lstIgnoreColumns = null, string where = "");
Task<bool> Update(Expression<Func<TEntity, TEntity>> columns, Expression<Func<TEntity, bool>> where);
9 months ago
#endregion
9 months ago
#region Split分表基础接口 基础CRUD
/// <summary>
9 months ago
/// 通过ID查询(自动分表)
/// </summary>
9 months ago
Task<TEntity> QueryByIdSplit(object objId);
/// <summary>
9 months ago
/// 分页查询(自动分表)
/// </summary>
9 months ago
Task<PageModel<TEntity>> QueryPageSplit(Expression<Func<TEntity, bool>> whereExpression, DateTime beginTime, DateTime endTime, int pageIndex = 1, int pageSize = 20, string orderByFields = null);
/// <summary>
9 months ago
/// 插入(自动分表)
/// </summary>
Task<List<long>> AddSplit(TEntity entity);
/// <summary>
9 months ago
/// 删除(自动分表)
/// </summary>
Task<bool> DeleteSplit(TEntity entity, DateTime dateTime);
/// <summary>
9 months ago
/// 更新(自动分表)
/// </summary>
Task<bool> UpdateSplit(TEntity entity, DateTime dateTime);
#endregion
}
}