diff --git a/Dapper.Lite/Dapper.Lite/Dapper.Lite.csproj b/Dapper.Lite/Dapper.Lite/Dapper.Lite.csproj
index b85781f..d922858 100644
--- a/Dapper.Lite/Dapper.Lite/Dapper.Lite.csproj
+++ b/Dapper.Lite/Dapper.Lite/Dapper.Lite.csproj
@@ -6,9 +6,9 @@
disable
True
Dapper.Lite
- 2.0.7
- 2.0.7
- 2.0.7
+ 2.0.8
+ 2.0.8
+ 2.0.8
Dapper.Lite
https://github.com/0611163/Dapper.Lite
MIT
@@ -20,7 +20,10 @@
更新内容:
- 1. 移除接口的where T : new()限制,以支持QueryList<string>
+ 1. 新增:IDbSession接口增加SetCommandType方法,以支持调用存储过程
+ 2. 优化:删除重复的OnExecuting调用
+ 3. 新增:IDbSession接口新增查询并返回DataTable的方法
+ 4. 新增:IDbSession接口增加设置Dapper参数的方法SetCommandTimeout和SetBuffered
diff --git a/Dapper.Lite/Dapper.Lite/Session/DbSession.cs b/Dapper.Lite/Dapper.Lite/Session/DbSession.cs
index c023afc..ce548df 100644
--- a/Dapper.Lite/Dapper.Lite/Session/DbSession.cs
+++ b/Dapper.Lite/Dapper.Lite/Session/DbSession.cs
@@ -86,6 +86,12 @@ public partial class DbSession : IDbSession
///
public DbConnection Conn => _tran?.Connection;
+ private CommandType _commandType = CommandType.Text;
+
+ private int? _commandTimeout = null; // Dapper参数
+
+ private bool _buffered = true; // Dapper参数
+
#endregion
#region 静态构造函数
@@ -254,5 +260,36 @@ public async Task GetOpenedConnectionAsync(DbTransaction tran = nu
}
#endregion
+ #region 设置CommandType
+ ///
+ /// 设置CommandType
+ ///
+ public IDbSession SetCommandType(CommandType commandType)
+ {
+ _commandType = commandType;
+ return this;
+ }
+ #endregion
+
+ #region Dapper参数设置
+ ///
+ /// 设置Dapper参数commandTimeout
+ ///
+ public IDbSession SetCommandTimeout(int? commandTimeout)
+ {
+ _commandTimeout = commandTimeout;
+ return this;
+ }
+
+ ///
+ /// 设置Dapper参数buffered
+ ///
+ public IDbSession SetBuffered(bool buffered)
+ {
+ _buffered = buffered;
+ return this;
+ }
+ #endregion
+
}
}
diff --git a/Dapper.Lite/Dapper.Lite/Session/DbSessionDelete.cs b/Dapper.Lite/Dapper.Lite/Session/DbSessionDelete.cs
index 9f3917d..b82f07f 100644
--- a/Dapper.Lite/Dapper.Lite/Session/DbSessionDelete.cs
+++ b/Dapper.Lite/Dapper.Lite/Session/DbSessionDelete.cs
@@ -47,8 +47,6 @@ public int DeleteById(string id)
Tuple delTmpl = _provider.CreateDeleteSqlTempldate();
sbSql.Append(string.Format(delTmpl.Item1 + " {0} " + delTmpl.Item2 + " {1}={2}", GetTableName(_provider, type), idNameWithQuote, _provider.GetParameterName(idName, idType)));
- OnExecuting?.Invoke(sbSql.ToString(), cmdParms);
-
return Execute(sbSql.ToString(), cmdParms);
}
#endregion
@@ -90,8 +88,6 @@ public async Task DeleteByIdAsync(string id)
Tuple delTmpl = _provider.CreateDeleteSqlTempldate();
sbSql.Append(string.Format(delTmpl.Item1 + " {0} " + delTmpl.Item2 + " {1}={2}", GetTableName(_provider, type), idNameWithQuote, _provider.GetParameterName(idName, idType)));
- OnExecuting?.Invoke(sbSql.ToString(), cmdParms);
-
return await ExecuteAsync(sbSql.ToString(), cmdParms);
}
#endregion
@@ -122,8 +118,6 @@ public int BatchDeleteByIds(string ids)
sbSql.Remove(sbSql.Length - 1, 1);
sbSql.Append(")");
- OnExecuting?.Invoke(sbSql.ToString(), cmdParms);
-
return Execute(sbSql.ToString(), cmdParms);
}
#endregion
@@ -153,8 +147,6 @@ public async Task BatchDeleteByIdsAsync(string ids)
sbSql.Remove(sbSql.Length - 1, 1);
sbSql.Append(")");
- OnExecuting?.Invoke(sbSql.ToString(), cmdParms);
-
return await ExecuteAsync(sbSql.ToString(), cmdParms);
}
#endregion
@@ -200,8 +192,6 @@ public int DeleteByCondition(Type type, string condition)
Tuple delTmpl = _provider.CreateDeleteSqlTempldate();
sbSql.Append(string.Format(delTmpl.Item1 + " {0} " + delTmpl.Item2 + " {1}", GetTableName(_provider, type), condition));
- OnExecuting?.Invoke(sbSql.ToString(), null);
-
return Execute(sbSql.ToString());
}
#endregion
@@ -219,8 +209,6 @@ public async Task DeleteByConditionAsync(Type type, string condition)
Tuple delTmpl = _provider.CreateDeleteSqlTempldate();
sbSql.Append(string.Format(delTmpl.Item1 + " {0} " + delTmpl.Item2 + " {1}", GetTableName(_provider, type), condition));
- OnExecuting?.Invoke(sbSql.ToString(), null);
-
return await ExecuteAsync(sbSql.ToString());
}
#endregion
@@ -265,8 +253,6 @@ public int DeleteByCondition(Type type, string condition, DbParameter[] cmdParms
Tuple delTmpl = _provider.CreateDeleteSqlTempldate();
sbSql.Append(string.Format(delTmpl.Item1 + " {0} " + delTmpl.Item2 + " {1}", GetTableName(_provider, type), condition));
- OnExecuting?.Invoke(sbSql.ToString(), cmdParms);
-
return Execute(sbSql.ToString(), cmdParms);
}
#endregion
@@ -284,8 +270,6 @@ public async Task DeleteByConditionAsync(Type type, string condition, DbPar
Tuple delTmpl = _provider.CreateDeleteSqlTempldate();
sbSql.Append(string.Format(delTmpl.Item1 + " {0} " + delTmpl.Item2 + " {1}", GetTableName(_provider, type), condition));
- OnExecuting?.Invoke(sbSql.ToString(), cmdParms);
-
return await ExecuteAsync(sbSql.ToString(), cmdParms);
}
#endregion
diff --git a/Dapper.Lite/Dapper.Lite/Session/DbSessionExecuteCommand.cs b/Dapper.Lite/Dapper.Lite/Session/DbSessionExecuteCommand.cs
index 12f63a7..4fda857 100644
--- a/Dapper.Lite/Dapper.Lite/Session/DbSessionExecuteCommand.cs
+++ b/Dapper.Lite/Dapper.Lite/Session/DbSessionExecuteCommand.cs
@@ -28,7 +28,6 @@ public partial class DbSession : IDbSession
public bool Exists(string sqlString)
{
SqlFilter(ref sqlString);
- OnExecuting?.Invoke(sqlString, null);
object obj = ExecuteScalar(sqlString);
@@ -50,7 +49,6 @@ public bool Exists(string sqlString)
public async Task ExistsAsync(string sqlString)
{
SqlFilter(ref sqlString);
- OnExecuting?.Invoke(sqlString, null);
object obj = await ExecuteScalarAsync(sqlString);
@@ -74,7 +72,6 @@ public async Task ExistsAsync(string sqlString)
public T QuerySingle(string sqlString)
{
SqlFilter(ref sqlString);
- OnExecuting?.Invoke(sqlString, null);
object obj = ExecuteScalar(sqlString);
@@ -97,7 +94,6 @@ public T QuerySingle(string sqlString)
public object QuerySingle(string sqlString)
{
SqlFilter(ref sqlString);
- OnExecuting?.Invoke(sqlString, null);
object obj = ExecuteScalar(sqlString);
@@ -120,7 +116,6 @@ public object QuerySingle(string sqlString)
public async Task QuerySingleAsync(string sqlString)
{
SqlFilter(ref sqlString);
- OnExecuting?.Invoke(sqlString, null);
object obj = await ExecuteScalarAsync(sqlString);
@@ -143,7 +138,6 @@ public async Task QuerySingleAsync(string sqlString)
public async Task