Dapper ORM库调用简单封装.
1. 项目引用Dapper作为直接访问, 为了使用方便, 封装一下.达到效果:
- 数据库连接配置在webconfig.xml中.
- 常用调用方法封装.
调用: //可以采用单例模式.
//全局实例
public static DapperEntity DBI
{
get
{
return DapperEntity.Instance;
}
}
//调用
public static DateTime GetDBDateTime()
{
return DBI.QueryFirst<DateTime>("SELECT GETDATE()");
}
参考单例:
private static object syncObj = new object();
private static DapperEntity instance;
public static DapperEntity Instance
{
get
{
if (instance == null)
{
lock (syncObj)
{
if (instance == null)
{
instance = DapperEntity.Instance
}
}
}
return instance;
}
}
封装类:
<add key="TSQLConnectionString" value=""/> //配置在webconfig.xml中
public class DapperEntity
{
private static DapperEntity instance;
private string ConnectionString;
private IDbConnection DefineConnection;
private IDbConnection DefaultConnection;
private IDbTransaction Transaction;
public static DapperEntity Instance
{
get
{
return new DapperEntity("");
}
}
public IDbConnection Connection
{
get
{
IDbConnection result;
if (this.DefineConnection != null)
{
result = this.DefineConnection;
}
else
{
if (this.DefaultConnection == null)
{
this.DefaultConnection = new SqlConnection(this.ConnectionString);
}
result = this.DefaultConnection;
}
return result;
}
}
public DapperEntity(string connectionStr = "")
{
if (string.IsNullOrEmpty(connectionStr))
{
connectionStr = ConfigurationManager.ConnectionStrings["TSQLDBConnectionString"].ConnectionString;
}
this.ConnectionString = connectionStr;
}
public DapperEntity(IDbConnection connection)
{
this.DefineConnection = connection;
}
public DataBaseType GetDataBaseType()
{
string name = this.Connection.GetType().Name;
string text = name;
DataBaseType result;
if (text != null)
{
if (text == "SQLiteConnection")
{
result = DataBaseType.SQLiteConnection;
return result;
}
if (!(text == "SqlConnection"))
{
}
}
result = DataBaseType.SqlConnection;
return result;
}
}
完整包括方法如下:
public class DapperEntity
{
private static DapperEntity instance;
private string ConnectionString;
private IDbConnection DefineConnection;
private IDbConnection DefaultConnection;
private IDbTransaction Transaction;
public static DapperEntity Instance
{
get
{
return new DapperEntity("");
}
}
public IDbConnection Connection
{
get
{
IDbConnection result;
if (this.DefineConnection != null)
{
result = this.DefineConnection;
}
else
{
if (this.DefaultConnection == null)
{
this.DefaultConnection = new SqlConnection(this.ConnectionString);
}
result = this.DefaultConnection;
}
return result;
}
}
public DapperEntity(string connectionStr = "")
{
if (string.IsNullOrEmpty(connectionStr))
{
connectionStr = ConfigurationManager.ConnectionStrings["TSQLDBConnectionString"].ConnectionString;
}
this.ConnectionString = connectionStr;
}
public DapperEntity(IDbConnection connection)
{
this.DefineConnection = connection;
}
public DataBaseType GetDataBaseType()
{
string name = this.Connection.GetType().Name;
string text = name;
DataBaseType result;
if (text != null)
{
if (text == "SQLiteConnection")
{
result = DataBaseType.SQLiteConnection;
return result;
}
if (!(text == "SqlConnection"))
{
}
}
result = DataBaseType.SqlConnection;
return result;
}
public object GetArrayFirst(object param)
{
object result;
if (param.GetType().BaseType.Name == "Array")
{
object[] array = param as object[];
if (array.Length == 0)
{
throw new Exception("数组不能为空");
}
result = array[0];
}
else
{
result = null;
}
return result;
}
private string BindQueryPageSql(string sql, PageQueryParams pqp)
{
int num = (pqp.PageIndex - 1) * pqp.PageSize;
int num2 = num + pqp.PageSize;
return string.Concat(new object[]
{
"select * from (select row_number()over(order by ",
pqp.OrderField,
" ",
pqp.OrderDirection.ToString(),
")rownumber,* from (",
sql,
")t1)t2 WHERE rownumber>",
num,
" and rownumber<=",
num2
});
}
public PageQueryModel<T> OQueryPage<T>(PageQueryParams pageQueryParams, string sql, object param = null, IDbTransaction transaction = null, bool buffered = true, int? commandTimeout = null, CommandType? commandType = null)
{
int total = Convert.ToInt32(this.Connection.ExecuteScalar("select count(*) from (" + sql + ")a", param, transaction, commandTimeout, commandType));
sql = this.BindQueryPageSql(sql, pageQueryParams);
return new PageQueryModel<T>
{
Total = total,
Data = this.Connection.Query(sql, param, transaction, buffered, commandTimeout, commandType)
};
}
[return: Dynamic(new bool[]
{
false,
true
})]
public PageQueryModel<dynamic> OQueryPage(PageQueryParams pageQueryParams, string sql, object param = null, IDbTransaction transaction = null, bool buffered = true, int? commandTimeout = null, CommandType? commandType = null)
{
int total = Convert.ToInt32(this.Connection.ExecuteScalar("select count(*) from (" + sql + ")a", param, transaction, commandTimeout, commandType));
sql = this.BindQueryPageSql(sql, pageQueryParams);
return new PageQueryModel<object>
{
Total = total,
Data = this.Connection.Query(sql, param, transaction, buffered, commandTimeout, commandType)
};
}
[return: Dynamic]
public dynamic OQueryFirstByPrimaryKey(object param, string tableName = null, string primaryKey = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser objectParser = ObjectParser.Bulid(param, tableName, primaryKey, true);
return this.QueryFirstOrDefault(string.Concat(new string[]
{
"select * from ",
objectParser.TableName,
" where ",
objectParser.PrimaryPropertyInfo.Name,
"=@",
objectParser.PrimaryPropertyInfo.Name
}), param, transaction, commandTimeout, null);
}
public T OQueryFirstByPrimaryKey<T>(object param, string primaryKey = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser objectParser = ObjectParser.Bulid<T>(param, primaryKey, true);
return this.QueryFirstOrDefault<T>(string.Concat(new string[]
{
"select * from ",
objectParser.TableName,
" where ",
objectParser.PrimaryPropertyInfo.Name,
"=@",
objectParser.PrimaryPropertyInfo.Name
}), param, transaction, commandTimeout, null);
}
[return: Dynamic(new bool[]
{
false,
true
})]
public IEnumerable<dynamic> OQuery(object param, string where = null, string tableName = null, IDbTransaction transaction = null)
{
ObjectParser objectParser = ObjectParser.Bulid(param, tableName, null, false);
return this.Query("select * from " + objectParser.TableName + ((!string.IsNullOrEmpty(where)) ? (" where " + where) : ""), param, transaction, true, null, null);
}
public IEnumerable<T> OQuery<T>(object param, string where = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser objectParser = ObjectParser.Bulid<T>(param, null, false);
return this.Query<T>("select * from " + objectParser.TableName + ((!string.IsNullOrEmpty(where)) ? (" where " + where) : ""), param, transaction, true, null, null);
}
[return: Dynamic]
public dynamic OQueryFirstOrDefault(object param, string where = null, string tableName = null, IDbTransaction transaction = null)
{
ObjectParser objectParser = ObjectParser.Bulid(param, tableName, null, false);
return this.QueryFirstOrDefault("select * from " + objectParser.TableName + ((!string.IsNullOrEmpty(where)) ? (" where " + where) : ""), param, transaction, null, null);
}
public T OQueryFirstOrDefault<T>(object param, string where = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser objectParser = ObjectParser.Bulid<T>(param, null, false);
return this.QueryFirstOrDefault<T>("select * from " + objectParser.TableName + ((!string.IsNullOrEmpty(where)) ? (" where " + where) : ""), param, transaction, null, null);
}
public void BeginTransaction()
{
this.Connection.Open();
this.Transaction = this.Connection.BeginTransaction();
}
public void CommitTransaction()
{
this.Transaction.Commit();
this.Connection.Close();
}
public void RollbackTransaction()
{
this.Transaction.Rollback();
this.Connection.Close();
}
public int OInsert(object param, string tableName = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser oParser = ObjectParser.Bulid(this.GetArrayFirst(param) ?? param, tableName, null, false);
return this.OInsertHandle(param, transaction ?? this.Transaction, commandTimeout, oParser);
}
public int OInsert<T>(object param, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser oParser = ObjectParser.Bulid<T>(this.GetArrayFirst(param) ?? param, null, false);
return this.OInsertHandle(param, transaction, commandTimeout, oParser);
}
private int OInsertHandle(object param, IDbTransaction transaction, int? commandTimeout, ObjectParser oParser)
{
return this.Execute(string.Concat(new string[]
{
"insert into ",
oParser.TableName,
"(",
oParser.GetSQL_InsertField(),
") values (",
oParser.GetSQL_InsertValue(),
")"
}), param, transaction, commandTimeout, null);
}
public int OUpdate(object param, string whereSql, object whereParam, string tableName = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser objectParser = ObjectParser.Bulid(param, tableName, null, false);
return this.Execute(string.Concat(new string[]
{
"update ",
objectParser.TableName,
" set ",
objectParser.GetSQL_UpdateFieldValue("", null),
" where ",
whereSql
}), param, transaction, commandTimeout, null);
}
public int OUpdateByPrimaryKey(object param, string tableName = null, string primaryKey = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser oParser = ObjectParser.Bulid(this.GetArrayFirst(param) ?? param, tableName, primaryKey, true);
return this.OUpdateByPrimaryKeyHandle(param, transaction, commandTimeout, oParser);
}
public int OUpdateByPrimaryKey<T>(object param, string primaryKey = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser oParser = ObjectParser.Bulid<T>(this.GetArrayFirst(param) ?? param, primaryKey, true);
return this.OUpdateByPrimaryKeyHandle(param, transaction, commandTimeout, oParser);
}
private int OUpdateByPrimaryKeyHandle(object param, IDbTransaction transaction, int? commandTimeout, ObjectParser oParser)
{
return this.Execute(string.Concat(new string[]
{
"update ",
oParser.TableName,
" set ",
oParser.GetSQL_UpdateFieldValue("", null),
" where ",
oParser.PrimaryPropertyInfo.Name,
"=@",
oParser.PrimaryPropertyInfo.Name
}), param, transaction, commandTimeout, null);
}
public int OUpdate(object param, string where, string tableName = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser oParser = ObjectParser.Bulid(this.GetArrayFirst(param) ?? param, tableName, null, false);
return this.OUpdateHandle(param, where, transaction, commandTimeout, oParser);
}
private int OUpdateHandle(object param, string where, IDbTransaction transaction, int? commandTimeout, ObjectParser oParser)
{
return this.Execute(string.Concat(new string[]
{
"update ",
oParser.TableName,
" set ",
oParser.GetSQL_UpdateFieldValue(where, null),
(!string.IsNullOrEmpty(where)) ? (" where " + where) : ""
}), param, transaction, commandTimeout, null);
}
public int OUpdate<T>(object param, string where, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser oParser = ObjectParser.Bulid<T>(this.GetArrayFirst(param) ?? param, null, false);
return this.OUpdateHandle(param, where, transaction, commandTimeout, oParser);
}
public int OInsertOrUpdate(object param, string tableName = null, string primaryKey = null, string[] UnUpdateColumns = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
object arrayFirst = this.GetArrayFirst(param);
bool flag = arrayFirst != null;
int result;
if (this.GetDataBaseType() == DataBaseType.SqlConnection)
{
ObjectParser objectParser = ObjectParser.Bulid(arrayFirst ?? param, tableName, primaryKey, true);
result = this.Execute(string.Concat(new string[]
{
"IF Not EXISTS (SELECT * FROM dbo.AppUserConfig WHERE UserID=@UserID) insert into ",
objectParser.TableName,
"(",
objectParser.GetSQL_InsertField(),
") values (",
objectParser.GetSQL_InsertValue(),
")ELSE update ",
objectParser.TableName,
" set ",
objectParser.GetSQL_UpdateFieldValue("", UnUpdateColumns),
" where ",
objectParser.PrimaryPropertyInfo.Name,
"=@",
objectParser.PrimaryPropertyInfo.Name
}), param, transaction, commandTimeout, null);
}
else
{
if (!flag)
{
if (!this.OExistByPrimaryKey(param, tableName, primaryKey, null))
{
result = this.OInsert(param, tableName, transaction, commandTimeout);
}
else
{
result = this.OUpdateByPrimaryKey(param, tableName, primaryKey, transaction, commandTimeout);
}
}
else
{
object[] array = param as object[];
int num = 0;
object[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
object obj = array2[i];
if (!this.OExistByPrimaryKey(param, tableName, primaryKey, null))
{
num += this.OInsert(param, tableName, transaction, commandTimeout);
}
else
{
num += this.OUpdateByPrimaryKey(param, tableName, primaryKey, transaction, commandTimeout);
}
}
result = num;
}
}
return result;
}
public int OInsertOrUpdate<T>(object param, string primaryKey = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
object arrayFirst = this.GetArrayFirst(param);
bool flag = arrayFirst != null;
int result;
if (this.GetDataBaseType() == DataBaseType.SqlConnection)
{
ObjectParser objectParser = ObjectParser.Bulid<T>(arrayFirst ?? param, primaryKey, true);
result = this.Execute(string.Concat(new string[]
{
"IF Not EXISTS (SELECT * FROM dbo.AppUserConfig WHERE UserID=@UserID) insert into ",
objectParser.TableName,
"(",
objectParser.GetSQL_InsertField(),
") values (",
objectParser.GetSQL_InsertValue(),
")ELSE update ",
objectParser.TableName,
" set ",
objectParser.GetSQL_UpdateFieldValue("", null),
" where ",
objectParser.PrimaryPropertyInfo.Name,
"=@",
objectParser.PrimaryPropertyInfo.Name
}), param, transaction, commandTimeout, null);
}
else
{
if (!flag)
{
if (!this.OExistByPrimaryKey<T>(param, primaryKey, null))
{
result = this.OInsert<T>(param, transaction, commandTimeout);
}
else
{
result = this.OUpdateByPrimaryKey<T>(param, primaryKey, transaction, commandTimeout);
}
}
else
{
object[] array = param as object[];
int num = 0;
object[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
object obj = array2[i];
if (!this.OExistByPrimaryKey<T>(param, primaryKey, null))
{
num += this.OInsert<T>(param, transaction, commandTimeout);
}
else
{
num += this.OUpdateByPrimaryKey<T>(param, primaryKey, transaction, commandTimeout);
}
}
result = num;
}
}
return result;
}
public bool OExistByPrimaryKey(object param, string tableName = null, string primaryKey = null, int? commandTimeout = null)
{
ObjectParser oParser = ObjectParser.Bulid(param, tableName, primaryKey, true);
return this.OExistByPrimaryKeyHandle(param, oParser);
}
public bool OExistByPrimaryKey<T>(object param, string primaryKey = null, int? commandTimeout = null)
{
ObjectParser oParser = ObjectParser.Bulid<T>(this.GetArrayFirst(param) ?? param, primaryKey, true);
return this.OExistByPrimaryKeyHandle(param, oParser);
}
private bool OExistByPrimaryKeyHandle(object param, ObjectParser oParser)
{
object value = this.ExecuteScalar(string.Concat(new string[]
{
"select count(*) from ",
oParser.TableName,
" where ",
oParser.PrimaryPropertyInfo.Name,
"=@",
oParser.PrimaryPropertyInfo.Name
}), param, null, null, null);
return Convert.ToInt32(value) > 0;
}
public int ODeleteByPrimaryKey(object param, string tableName = null, string primaryKey = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser oParser = ObjectParser.Bulid(this.GetArrayFirst(param) ?? param, tableName, primaryKey, true);
return this.ODeleteByPrimaryKeyHandle(param, transaction, commandTimeout, oParser);
}
public int ODeleteByPrimaryKey<T>(object param, string primaryKey = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser oParser = ObjectParser.Bulid<T>(this.GetArrayFirst(param) ?? param, primaryKey, true);
return this.ODeleteByPrimaryKeyHandle(param, transaction, commandTimeout, oParser);
}
private int ODeleteByPrimaryKeyHandle(object param, IDbTransaction transaction, int? commandTimeout, ObjectParser oParser)
{
return this.Execute(string.Concat(new string[]
{
"delete from ",
oParser.TableName,
" where ",
oParser.PrimaryPropertyInfo.Name,
"=@",
oParser.PrimaryPropertyInfo.Name
}), param, transaction, commandTimeout, null);
}
public int ODelete(object param, string where, string tableName = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser oParser = ObjectParser.Bulid(this.GetArrayFirst(param) ?? param, tableName, null, false);
return this.ODeleteHandle(param, where, transaction, commandTimeout, oParser);
}
public int ODelete<T>(object param, string where, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser oParser = ObjectParser.Bulid<T>(this.GetArrayFirst(param) ?? param, null, false);
return this.ODeleteHandle(param, where, transaction, commandTimeout, oParser);
}
private int ODeleteHandle(object param, string where, IDbTransaction transaction, int? commandTimeout, ObjectParser oParser)
{
return this.Execute("delete from " + oParser.TableName + ((!string.IsNullOrEmpty(where)) ? (" where " + where) : ""), param, transaction, commandTimeout, null);
}
public int OCount(object param, string where = null, string tableName = null, IDbTransaction transaction = null)
{
ObjectParser objectParser = ObjectParser.Bulid(param, tableName, null, false);
return this.QuerySingle<int>("select count(*) from " + objectParser.TableName + ((!string.IsNullOrEmpty(where)) ? (" where " + where) : ""), param, transaction, null, null);
}
public int OCount<T>(object param, string where = null, IDbTransaction transaction = null, int? commandTimeout = null)
{
ObjectParser objectParser = ObjectParser.Bulid<T>(param, null, false);
return this.QuerySingle<int>("select count(*) from " + objectParser.TableName + ((!string.IsNullOrEmpty(where)) ? (" where " + where) : ""), param, transaction, null, null);
}
public int Execute(CommandDefinition command)
{
return this.Connection.Execute(command);
}
public int Execute(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.Execute(sql, param, transaction, commandTimeout, commandType);
}
public IDataReader ExecuteReader(CommandDefinition command)
{
return this.Connection.ExecuteReader(command);
}
public IDataReader ExecuteReader(CommandDefinition command, CommandBehavior commandBehavior)
{
return this.Connection.ExecuteReader(command, commandBehavior);
}
public IDataReader ExecuteReader(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.ExecuteReader(sql, param, transaction, commandTimeout, commandType);
}
public T ExecuteScalar<T>(CommandDefinition command)
{
return this.Connection.ExecuteScalar(command);
}
public object ExecuteScalar(CommandDefinition command)
{
return this.Connection.ExecuteScalar(command);
}
public T ExecuteScalar<T>(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.ExecuteScalar(sql, param, transaction, commandTimeout, commandType);
}
public object ExecuteScalar(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.ExecuteScalar(sql, param, transaction, commandTimeout, commandType);
}
public IEnumerable<T> Query<T>(CommandDefinition command)
{
return this.Connection.Query(command);
}
public IEnumerable<T> Query<T>(string sql, object param = null, IDbTransaction transaction = null, bool buffered = true, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.Query(sql, param, transaction, buffered, commandTimeout, commandType);
}
[return: Dynamic(new bool[]
{
false,
true
})]
public IEnumerable<dynamic> Query(string sql, object param = null, IDbTransaction transaction = null, bool buffered = true, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.Query(sql, param, transaction, buffered, commandTimeout, commandType);
}
public IEnumerable<object> Query(Type type, string sql, object param = null, IDbTransaction transaction = null, bool buffered = true, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.Query(type, sql, param, transaction, buffered, commandTimeout, commandType);
}
public IEnumerable<TReturn> Query<TFirst, TSecond, TReturn>(string sql, Func<TFirst, TSecond, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.Query(sql, map, param, transaction, buffered, splitOn, commandTimeout, commandType);
}
public IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TFourth, TFifth, TReturn>(string sql, Func<TFirst, TSecond, TThird, TFourth, TFifth, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.Query(sql, map, param, transaction, buffered, splitOn, commandTimeout, commandType);
}
public IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn>(string sql, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.Query(sql, map, param, transaction, buffered, splitOn, commandTimeout, commandType);
}
public IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(string sql, Func<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.Query(sql, map, param, transaction, buffered, splitOn, commandTimeout, commandType);
}
public IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TFourth, TReturn>(string sql, Func<TFirst, TSecond, TThird, TFourth, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.Query(sql, map, param, transaction, buffered, splitOn, commandTimeout, commandType);
}
public IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TReturn>(string sql, Func<TFirst, TSecond, TThird, TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.Query(sql, map, param, transaction, buffered, splitOn, commandTimeout, commandType);
}
public IEnumerable<TReturn> Query<TReturn>(string sql, Type[] types, Func<object[], TReturn> map, object param = null, IDbTransaction transaction = null, bool buffered = true, string splitOn = "Id", int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.Query(sql, types, map, param, transaction, buffered, splitOn, commandTimeout, commandType);
}
public T QueryFirst<T>(CommandDefinition command)
{
return this.Connection.QueryFirst(command);
}
[return: Dynamic]
public dynamic QueryFirst(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.QueryFirst(sql, param, transaction, commandTimeout, commandType);
}
public T QueryFirst<T>(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.QueryFirst(sql, param, transaction, commandTimeout, commandType);
}
public object QueryFirst(Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.QueryFirst(type, sql, param, transaction, commandTimeout, commandType);
}
public T QueryFirstOrDefault<T>(CommandDefinition command)
{
return this.Connection.QueryFirstOrDefault(command);
}
[return: Dynamic]
public dynamic QueryFirstOrDefault(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.QueryFirstOrDefault(sql, param, transaction, commandTimeout, commandType);
}
public T QueryFirstOrDefault<T>(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.QueryFirstOrDefault(sql, param, transaction, commandTimeout, commandType);
}
public object QueryFirstOrDefault(Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.QueryFirstOrDefault(type, sql, param, transaction, commandTimeout, commandType);
}
public SqlMapper.GridReader QueryMultiple(CommandDefinition command)
{
return this.Connection.QueryMultiple(command);
}
public SqlMapper.GridReader QueryMultiple(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.QueryMultiple(sql, param, transaction, commandTimeout, commandType);
}
public T QuerySingle<T>(CommandDefinition command)
{
return this.Connection.QuerySingle(command);
}
[return: Dynamic]
public dynamic QuerySingle(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.QuerySingle(sql, param, transaction, commandTimeout, commandType);
}
public T QuerySingle<T>(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.QuerySingle(sql, param, transaction, commandTimeout, commandType);
}
public object QuerySingle(Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.QuerySingle(type, sql, param, transaction, commandTimeout, commandType);
}
public T QuerySingleOrDefault<T>(CommandDefinition command)
{
return this.Connection.QuerySingleOrDefault(command);
}
[return: Dynamic]
public dynamic QuerySingleOrDefault(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.QuerySingleOrDefault(sql, param, transaction, commandTimeout, commandType);
}
public T QuerySingleOrDefault<T>(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.QuerySingleOrDefault(sql, param, transaction, commandTimeout, commandType);
}
public object QuerySingleOrDefault(Type type, string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return this.Connection.QuerySingleOrDefault(type, sql, param, transaction, commandTimeout, commandType);
}
}
在未知中徜徉,
求心之荡漾。