using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq.Expressions; using Dapper; namespace Tiobon.Core.Common.DB.Dapper; public interface ITransDapper { void BeginTransaction(Func action, Action error, bool disposeConn = true); /// /// var p = new object(); // p.Add("@a", 11); //p.Add("@b", dbType: DbType.Int32, direction: ParameterDirection.Output); //p.Add("@c", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue); // /// /// /// /// /// /// List QueryList(string cmd, object param, CommandType? commandType = null) where T : class; T QueryFirst(string cmd, object param, CommandType? commandType = null) where T : class; object ExecuteScalar(string cmd, object param, CommandType? commandType = null); int ExcuteNonQuery(string cmd, object param, CommandType? commandType = null); IDataReader ExecuteReader(string cmd, object param, CommandType? commandType = null); SqlMapper.GridReader QueryMultiple(string cmd, object param, CommandType? commandType = null); (List, List) QueryMultiple(string cmd, object param, CommandType? commandType = null); (List, List, List) QueryMultiple(string cmd, object param, CommandType? commandType = null); /// /// /// /// /// /// 指定插入的字段 /// 是否开启事务 /// int Add(T entity, Expression> updateFileds = null); /// /// /// /// /// /// 指定插入的字段 /// 是否开启事务 /// int AddRange(IEnumerable entities, Expression> updateFileds = null); /// /// sqlserver使用的临时表参数化批量更新,mysql批量更新待发开 /// /// /// 实体必须带主键 /// 指定更新的字段x=new {x.a,x.b} /// 是否开启事务 /// int Update(T entity, Expression> updateFileds = null); /// /// sqlserver使用的临时表参数化批量更新,mysql批量更新待发开 /// /// /// 实体必须带主键 /// 指定更新的字段x=new {x.a,x.b} /// 是否开启事务 /// int UpdateRange(IEnumerable entities, Expression> updateFileds = null); int DelWithKey(params object[] 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); DataTable GetDataTable(string cmd, object param, CommandType? commandType = null); }