using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace SqlSugar
{
///
/// 非泛型 SqlSugar 仓储
///
public partial interface ISqlSugarRepository
{
///
/// 切换仓储
///
/// 实体类型
/// 仓储
ISqlSugarRepository Change()
where TEntity : class, new();
}
///
/// SqlSugar 仓储接口定义
///
///
public partial interface ISqlSugarRepository
where TEntity : class, new()
{
///
/// 实体集合
///
ISugarQueryable Entities { get; }
///
/// 数据库上下文
///
SqlSugarClient Context { get; }
///
/// 动态数据库上下文
///
dynamic DynamicContext { get; }
///
/// 原生 Ado 对象
///
IAdo Ado { get; }
///
/// 获取总数
///
///
///
int Count(Expression> whereExpression);
///
/// 获取总数
///
///
///
Task CountAsync(Expression> whereExpression);
///
/// 检查是否存在
///
///
///
bool Any(Expression> whereExpression);
///
/// 检查是否存在
///
///
///
Task AnyAsync(Expression> whereExpression);
///
/// 通过主键获取实体
///
///
///
TEntity Single(dynamic Id);
///
/// 获取一个实体
///
///
///
TEntity Single(Expression> whereExpression);
///
/// 获取一个实体
///
///
///
Task SingleAsync(Expression> whereExpression);
///
/// 获取一个实体
///
///
///
TEntity FirstOrDefault(Expression> whereExpression);
///
/// 获取一个实体
///
///
///
Task FirstOrDefaultAsync(Expression> whereExpression);
///
/// 获取列表
///
///
List ToList();
///
/// 获取列表
///
///
///
List ToList(Expression> whereExpression);
///
/// 获取列表
///
///
///
///
///
List ToList(Expression> whereExpression, Expression> orderByExpression = null, OrderByType orderByType = OrderByType.Asc);
///
/// 获取列表
///
///
Task> ToListAsync();
///
/// 获取列表
///
///
///
Task> ToListAsync(Expression> whereExpression);
///
/// 获取列表
///
///
///
///
///
Task> ToListAsync(Expression> whereExpression, Expression> orderByExpression = null, OrderByType orderByType = OrderByType.Asc);
///
/// 新增一条记录
///
///
///
int Insert(TEntity entity);
///
/// 新增多条记录
///
///
///
int Insert(params TEntity[] entities);
///
/// 新增多条记录
///
///
///
int Insert(IEnumerable entities);
///
/// 新增一条记录返回自增Id
///
///
///
int InsertReturnIdentity(TEntity entity);
///
/// 新增一条记录
///
///
///
Task InsertAsync(TEntity entity);
///
/// 新增多条记录
///
///
///
Task InsertAsync(params TEntity[] entities);
///
/// 新增多条记录
///
///
///
Task InsertAsync(IEnumerable entities);
///
/// 新增一条记录返回自增Id
///
///
///
Task InsertReturnIdentityAsync(TEntity entity);
///
/// 更新一条记录
///
///
///
int Update(TEntity entity);
///
/// 更新多条记录
///
///
///
int Update(params TEntity[] entities);
///
/// 更新多条记录
///
///
///
int Update(IEnumerable entities);
///
/// 更新一条记录
///
///
///
Task UpdateAsync(TEntity entity);
///
/// 无主键更新一条记录
///
/// 更新的实体
/// 根据那些字段更新
///
Task UpdateNoPrimaryKey(TEntity entity, Expression> columns);
///
/// 无主键更新多条记录
///
/// 更新的实体
/// 根据那些字段更新
///
Task UpdateNoPrimaryKeyAsync(List entitys, Expression> columns);
///
/// 无主键更新多条记录
///
/// 更新的实体
/// 根据那些字段更新
///
Task UpdateNoPrimaryKey(List entitys, Expression> columns);
///
/// 无主键更新一条记录
///
/// 更新的实体
/// 根据那些字段更新
///
Task UpdateNoPrimaryKeyAsync(TEntity entity, Expression> columns);
///
/// 更新多条记录
///
///
///
Task UpdateAsync(params TEntity[] entities);
///
/// 更新多条记录
///
///
///
Task UpdateAsync(IEnumerable entities);
///
/// 删除一条记录
///
///
///
int Delete(TEntity entity);
///
/// 删除一条记录
///
///
///
int Delete(object key);
///
/// 删除多条记录
///
///
///
int Delete(params object[] keys);
///
/// 自定义条件删除记录
///
///
///
int Delete(Expression> whereExpression);
///
/// 删除一条记录
///
///
///
Task DeleteAsync(TEntity entity);
///
/// 删除一条记录
///
///
///
Task DeleteAsync(object key);
///
/// 删除多条记录
///
///
///
Task DeleteAsync(params object[] keys);
///
/// 自定义条件删除记录
///
///
///
Task DeleteAsync(Expression> whereExpression);
bool IsExists(Expression> whereExpression);
Task IsExistsAsync(Expression> whereExpression);
///
/// 根据表达式查询多条记录
///
///
///
ISugarQueryable Where(Expression> predicate);
///
/// 根据表达式查询多条记录
///
///
///
///
ISugarQueryable Where(bool condition, Expression> predicate);
///
/// 构建查询分析器
///
///
ISugarQueryable AsQueryable();
///
/// 构建查询分析器
///
///
///
ISugarQueryable AsQueryable(Expression> predicate);
///
/// 直接返回数据库结果
///
///
List AsEnumerable();
///
/// 直接返回数据库结果
///
///
///
List AsEnumerable(Expression> predicate);
///
/// 直接返回数据库结果
///
///
Task> AsAsyncEnumerable();
///
/// 直接返回数据库结果
///
///
///
Task> AsAsyncEnumerable(Expression> predicate);
///
/// 切换仓储
///
///
///
ISqlSugarRepository Change() where TChangeEntity : class, new();
}
}