using Dapper; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq.Expressions; namespace WIDESEA_Core.Dapper { public interface ISqlDapper { void BeginTransaction(Func action, Action error); /// /// 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, bool beginTransaction = false) where T : class; T QueryFirst(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false) where T : class; object ExecuteScalar(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); int ExcuteNonQuery(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); (List, List) QueryMultiple(string cmd, object param, CommandType? commandType = null, bool beginTransaction = false); (List, List, List) QueryMultiple(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); int DelWithKey(params object[] keys); int DelWithKey(bool beginTransaction = false, 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); } }