using Learun.Util;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace Learun.DataBase.Repository
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创建人:陈彬彬
/// 日 期:2017.03.04
/// 描 述:定义仓储模型中的数据标准操作接口
///
public interface IRepository
{
#region 连接信息
///
/// 获取连接上下文
///
///
DbConnection getDbConnection();
#endregion
#region 事务
///
/// 开始事务
///
///
IRepository BeginTrans();
///
/// 提交
///
void Commit();
///
/// 回滚
///
void Rollback();
#endregion
#region 执行 SQL 代码
Task ExecuteAsyncBySql(string strSql);
///
/// 执行sql语句
///
/// sql语句
///
int ExecuteBySql(string strSql);
///
/// 执行sql语句
///
/// sql语句
/// 参数
///
int ExecuteBySql(string strSql, object dbParameter);
///
/// 执行存储过程
///
/// 存储过程名称
///
int ExecuteByProc(string procName);
///
/// 执行存储过程
///
/// 存储过程名称
/// 参数
///
int ExecuteByProc(string procName, object dbParameter);
///
/// 执行存储过程
///
/// 存储过程名称
///
T ExecuteByProc(string procName) where T : class;
///
/// 执行存储过程
///
/// 存储过程名称
/// 参数
///
T ExecuteByProc(string procName, object dbParameter) where T : class;
///
/// 执行存储过程
///
/// 存储过程名称
///
IEnumerable QueryByProc(string procName) where T : class;
///
/// 执行存储过程
///
/// 存储过程名称
/// 参数
///
IEnumerable QueryByProc(string procName, object dbParameter) where T : class;
#endregion
#region 对象实体 添加、修改、删除
///
/// 插入实体数据
///
/// 类型
/// 实体数据
///
int Insert(T entity) where T : class;
Task InsertAsync(List entity) where T : class;
///
/// 批量插入实体数据
///
/// 类型
/// 实体数据列表
///
int Insert(List entity) where T : class;
///
/// 删除实体数据
///
/// 类型
/// 实体数据(需要主键赋值)
///
int Delete(T entity) where T : class;
///
/// 批量删除实体数据
///
/// 类型
/// 实体数据列表
///
int Delete(List entity) where T : class;
///
/// 删除表数据(根据Lambda表达式)
///
///
///
///
int Delete(Expression> condition) where T : class, new();
///
/// 更新实体数据
///
/// 类型
/// 实体数据
///
int Update(T entity) where T : class;
///
/// 更新实体数据
///
/// 类型
/// 实体数据
///
int UpdateEx(T entity) where T : class;
///
/// 批量更新实体数据
///
/// 类型
/// 实体数据列表
///
int Update(List entity) where T : class;
#endregion
#region 对象实体 查询
///
/// 查找一个实体根据主键
///
/// 类型
/// 主键
///
T FindEntity(object keyValue) where T : class;
///
/// 查找一个实体(根据表达式)
///
/// 类型
/// 表达式
///
T FindEntity(Expression> condition) where T : class, new();
///
/// 查找一个实体(根据sql)
///
/// 类型
/// sql语句
/// 参数
///
T FindEntity(string strSql, object dbParameter) where T : class, new();
///
/// 获取IQueryable表达式
///
/// 类型
///
IQueryable IQueryable() where T : class, new();
///
/// 获取IQueryable表达式(根据表达式)
///
/// 类型
/// 表达式
///
IQueryable IQueryable(Expression> condition) where T : class, new();
///
/// 查询列表(获取表所有数据)
///
/// 类型
///
IEnumerable FindList() where T : class, new();
Task> FindListAsync() where T : class, new();
Task> FindListAsync(string strSql, object dbParameter) where T : class;
Task> FindListAsync(string strSql) where T : class;
///
/// 查询列表根据sql语句
///
/// 类型
/// sql语句
///
IEnumerable FindList(string strSql) where T : class;
///
/// 查询列表根据sql语句(带参数)
///
/// 类型
/// sql语句
/// 参数
///
IEnumerable FindList(string strSql, object dbParameter) where T : class;
///
/// 查询列表(分页)
///
/// 类型
/// 分页数据
///
IEnumerable FindList(Pagination pagination) where T : class, new();
IEnumerable FindList(List data, Pagination pagination) where T : class, new();
IEnumerable FindList(List data, Expression> condition, Pagination pagination) where T : class, new();
///
/// 查询列表(分页)
///
/// 类型
/// 表达式
/// 分页数据
///
IEnumerable FindList(Expression> condition, Pagination pagination) where T : class, new();
///
/// 查询数据
///
/// 类型
/// 表达式
///
IEnumerable FindList(Expression> condition) where T : class, new();
///
/// 查询列表(分页)
///
/// 类型
/// SQL语句
/// 分页数据
///
IEnumerable FindList(string strSql, Pagination pagination) where T : class;
///
/// 查询列表(分页)
///
/// 类型
/// SQL语句
/// 参数
/// 分页数据
///
IEnumerable FindList(string strSql, object dbParameter, Pagination pagination) where T : class;
#endregion
#region 数据源查询
///
/// 查询数据
///
/// sql语句
///
DataTable FindTable(string strSql);
///
/// 查询数据
///
/// sql语句
/// 参数
///
DataTable FindTable(string strSql, object dbParameter);
///
/// 查询列表(分页)
///
/// sql语句
/// 分页数据
///
DataTable FindTable(string strSql, Pagination pagination);
///
/// 查询列表(分页)
///
/// sql语句
/// 参数
/// 分页数据
///
DataTable FindTable(string strSql, object dbParameter, Pagination pagination);
///
/// 获取查询对象
///
/// SQL语句
///
object FindObject(string strSql);
///
/// 获取查询对象
///
/// sql语句
/// 参数
///
object FindObject(string strSql, object dbParameter);
#endregion
#region 扩展方法
///
/// 获取数据库表数据
///
/// 反序列化类型
///
IEnumerable GetDBTable() where T : class, new();
///
/// 获取数据库表字段数据
///
/// 反序列化类型
/// 表名
///
IEnumerable GetDBTableFields(string tableName) where T : class, new();
#endregion
}
}