|
|
using Dapper;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace Common.Repository.Interface
|
|
|
{
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
public interface IDapperDBBase
|
|
|
{
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
IDbConnection GetConn();
|
|
|
/// <summary>
|
|
|
/// 无参数存储过程
|
|
|
/// </summary>
|
|
|
/// <param name="SPName">存储过程名称</param>
|
|
|
/// <returns>返回值List<T></returns>
|
|
|
List<T> QuerySP<T>(string SPName);
|
|
|
|
|
|
/// <summary>
|
|
|
/// 有参数存储过程
|
|
|
/// </summary>
|
|
|
/// <param name="SPName">存储过程名称</param>
|
|
|
/// <returns>返回值List<T></returns>
|
|
|
List<T> QuerySP<T>(string SPName, object parms);
|
|
|
|
|
|
/// <summary>
|
|
|
/// 无参数异步存储过程
|
|
|
/// </summary>
|
|
|
/// <param name="SPName">存储过程名称</param>
|
|
|
/// <returns>返回值List<T></returns>
|
|
|
Task<List<T>> QuerySPAsync<T>(string SPName);
|
|
|
/// <summary>
|
|
|
/// 无参数异步存储过程
|
|
|
/// </summary>
|
|
|
/// <param name="SPName">存储过程名称</param>
|
|
|
/// <returns>返回值List<T></returns>
|
|
|
Task<List<T>> QuerySPAsync<T>(string SPName, object parms);
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="SPName"></param>
|
|
|
/// <param name="parms"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<int> ExecSPTransAsync(string SPName, object parms);
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="SPName"></param>
|
|
|
/// <param name="parms"></param>
|
|
|
/// <param name="conn"></param>
|
|
|
/// <param name="tran"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<int> ExecSPTransAsync(string SPName, object parms, IDbConnection conn, IDbTransaction tran);
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="SPName"></param>
|
|
|
/// <param name="parms"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<int> ExecSPAsync(string SPName, object parms);
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="Sql"></param>
|
|
|
/// <param name="parms"></param>
|
|
|
/// <param name="commandType"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<DataSet> QueryDataSetAsync(string Sql, object parms, CommandType commandType);
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="insertSql"></param>
|
|
|
/// <param name="parms"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<int> InsertAsync(string insertSql, object parms);
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="updateSql"></param>
|
|
|
/// <param name="parms"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<int> UpdateAsync(string updateSql, object parms);
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="Id"></param>
|
|
|
/// <param name="deleteSql"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<int> DeleteAsync(int Id, string deleteSql);
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
/// <param name="selectSql"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<List<T>> SelectAsync<T>(string selectSql);
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
/// <param name="Id"></param>
|
|
|
/// <param name="detailSql"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<T> DetailFirstAsync<T>(int Id, string detailSql);
|
|
|
|
|
|
//以下为dapper扩展方法,根据实体模型进行CRUD操作
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
/// <param name="id"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<T> QueryOneAsync<T>(int id) where T : class;
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
/// <returns></returns>
|
|
|
Task<IEnumerable<T>> QueryAllAsync<T>() where T : class;
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
/// <param name="entitys"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<long> InsertByEntitysAsync<T>(IEnumerable<T> entitys) where T : class;
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
/// <param name="entity"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<long> InsertByEntityAsync<T>(T entity) where T : class;
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
/// <param name="entitys"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<bool> UpdateByEntitysAsync<T>(IEnumerable<T> entitys) where T : class;
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
/// <param name="entity"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<bool> UpdateByEntityAsync<T>(T entity) where T : class;
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
/// <param name="entitys"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<bool> DeleteByEntitysAsync<T>(IEnumerable<T> entitys) where T : class;
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
/// <param name="entity"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<bool> DeleteByEntityAsync<T>(T entity) where T : class;
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
/// <param name="sql"></param>
|
|
|
/// <param name="parms"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<T> QuerySingleOrDefaultAsync<T>(string sql, object parms);
|
|
|
/// <summary>
|
|
|
/// 默认返回第一条数据
|
|
|
/// </summary>
|
|
|
/// <typeparam name="T">返回类型</typeparam>
|
|
|
/// <param name="sql">查询语句</param>
|
|
|
/// <returns></returns>
|
|
|
Task<T> QueryFirstOrDefaultAsync<T>(string sql);
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="querySQL"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<DataTable> QueryToDatableAsync(string querySQL);
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="querySQL"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<DataTable> QueryToDatableAsync(string querySQL, DynamicParameters parms);
|
|
|
/// <summary>
|
|
|
/// 执行SQL语句返回结果
|
|
|
/// </summary>
|
|
|
/// <param name="Sql"></param>
|
|
|
/// <param name="parms"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<T> ExecuteScalarAsync<T>(string Sql, object parms);
|
|
|
/// <summary>
|
|
|
/// 执行中包含事务sql
|
|
|
/// </summary>
|
|
|
/// <param name="listSql"></param>
|
|
|
/// <returns></returns>
|
|
|
Task<int> ExecSqlTransAsync(List<string> listSql);
|
|
|
}
|
|
|
}
|