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#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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>
ISqlSugarClient Db { get; }
#region 查询
Task<TEntity> QueryById(object objId);
Task<TEntity> QueryById(object objId, bool blnUseCache = false);
Task<List<TEntity>> QueryByIDs(object[] lstIds);
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>
/// 两表联查
/// </summary>
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>
/// 两表联查-分页
/// </summary>
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>
/// 两表联合查询-分页-分组
/// </summary>
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>
/// 三表联查
/// </summary>
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>
/// 三表联查-分页
/// </summary>
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
#region 新增
Task<long> Add(TEntity model);
Task<List<long>> Add(List<TEntity> listEntity);
#endregion
#region 删除
Task<bool> Delete(Expression<Func<TEntity, bool>> whereExpression);
Task<bool> DeleteById(object id);
Task<bool> Delete(TEntity model);
Task<bool> DeleteByIds(object[] ids);
#endregion
#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, bool>> columns, Expression<Func<TEntity, bool>> where);
#endregion
#region Split分表基础接口 基础CRUD
/// <summary>
/// 通过ID查询(自动分表)
/// </summary>
Task<TEntity> QueryByIdSplit(object objId);
/// <summary>
/// 分页查询(自动分表)
/// </summary>
Task<PageModel<TEntity>> QueryPageSplit(Expression<Func<TEntity, bool>> whereExpression, DateTime beginTime, DateTime endTime, int pageIndex = 1, int pageSize = 20, string orderByFields = null);
/// <summary>
/// 插入(自动分表)
/// </summary>
Task<List<long>> AddSplit(TEntity entity);
/// <summary>
/// 删除(自动分表)
/// </summary>
Task<bool> DeleteSplit(TEntity entity, DateTime dateTime);
/// <summary>
/// 更新(自动分表)
/// </summary>
Task<bool> UpdateSplit(TEntity entity, DateTime dateTime);
#endregion
}
}