using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq.Expressions; using System.Threading.Tasks; using Dapper; namespace VOL.Core.Dapper { public interface ISqlDapper { /// /// 超时时间(秒)2021.05.05 /// /// /// ISqlDapper SetTimout(int timeout); void BeginTransaction(Func action, Action error); List QueryList(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); Task> QueryListAsync(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); T QueryFirst(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false) where T : class; Task QueryFirstAsync(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false) where T : class; Task QueryDynamicFirstAsync(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); dynamic QueryDynamicFirst(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); Task QueryDynamicListAsync(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); List QueryDynamicList(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); object ExecuteScalar(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); Task ExecuteScalarAsync(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); int ExcuteNonQuery(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); Task ExcuteNonQueryAsync(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); //IDataReader ExecuteReader(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); SqlMapper.GridReader QueryMultiple(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); Task<(IEnumerable, IEnumerable)> QueryMultipleAsync(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); (List, List) QueryMultiple(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); Task<(IEnumerable, IEnumerable, IEnumerable)> QueryMultipleAsync(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); (List, List, List) QueryMultiple(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); Task<(IEnumerable, IEnumerable)> QueryDynamicMultipleAsync(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); (List, List) QueryDynamicMultiple(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); Task<(IEnumerable, IEnumerable, IEnumerable, IEnumerable)> QueryMultipleAsync(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); (List, List, List, List) QueryMultiple(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); Task<(IEnumerable, IEnumerable, IEnumerable, IEnumerable, IEnumerable)> QueryMultipleAsync(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); (List, List, List, List, List) QueryMultiple(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); Task<(IEnumerable, IEnumerable)> QueryDynamicMultipleAsync2(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); (List, List) QueryDynamicMultiple2(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); Task<(IEnumerable, IEnumerable, IEnumerable)> QueryDynamicMultipleAsync3(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); (List, List, List) QueryDynamicMultiple3(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); Task<(IEnumerable, IEnumerable, IEnumerable, IEnumerable, IEnumerable)> QueryDynamicMultipleAsync5(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); (List, List, List, List, List) QueryDynamicMultiple5(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); /// /// /// /// /// /// 指定插入的字段 /// 是否开启事务 /// int Add(T entity, Expression> updateFileds = null, bool beginTransaction = false); /// /// /// /// /// /// 指定插入的字段 /// 是否开启事务 /// int AddRange(IEnumerable entities, Expression> updateFileds = null, bool beginTransaction = false); /// /// sqlserver使用的临时表参数化批量更新,mysql批量更新待发开 /// /// /// 实体必须带主键 /// 指定更新的字段x=new {x.a,x.b} /// 是否开启事务 /// int Update(T entity, Expression> updateFileds = null, bool beginTransaction = false); /// /// sqlserver使用的临时表参数化批量更新,mysql批量更新待发开 /// /// /// 实体必须带主键 /// 指定更新的字段x=new {x.a,x.b} /// 是否开启事务 /// int UpdateRange(IEnumerable entities, Expression> updateFileds = null, bool beginTransaction = false); /// /// 使用key批量删除 /// 调用方式: /// List keys = new List(); /// DBServerProvider.SqlDapper.DelWithKey(keys); /// /// /// /// int DelWithKey(IEnumerable keys); /// /// sqlserver批量写入 /// 使用时DataTable table表字段顺序要和数据库字段顺序一致 /// /// mysql批量写入 /// /// /// /// 默认当前下载路径 /// 默认$"{DateTime.Now.ToString("yyyyMMddHHmmss")}.csv" /// int BulkInsert(DataTable table, string tableName, SqlBulkCopyOptions? sqlBulkCopyOptions = null, string fileName = null, string tmpPath = null); /// /// /// /// /// /// /// 所包含的列 /// /// /// /// int BulkInsert(List entities, string tableName = null, Expression> columns = null, SqlBulkCopyOptions? sqlBulkCopyOptions = null); /// /// 开启事务 /// /// ISqlDapper BeginTrans(); /// /// 提交 /// void Commit(); /// /// 回滚 /// void Rollback(); DataTable QueryDataTable(string sql, object dbParameter, CommandType commandType = CommandType.StoredProcedure); } }