- 增加 IUpdate.ExecuteUpdated 指定字段返回;

This commit is contained in:
2881099 2023-12-10 23:55:04 +08:00
parent 7ed542d859
commit 543ce4f513
19 changed files with 203 additions and 72 deletions

View File

@ -193,11 +193,15 @@ namespace FreeSql.Tests.SqlServer
g.sqlserver.Insert<Topic>().AppendData(new Topic()).ExecuteAffrows(); g.sqlserver.Insert<Topic>().AppendData(new Topic()).ExecuteAffrows();
var items = g.sqlserver.Select<Topic>().Limit(2).ToList(); var items = g.sqlserver.Select<Topic>().Limit(2).ToList();
g.sqlserver.Update<Topic>(items).SetRaw("Title='test'").ExecuteUpdated(); Assert.Equal("test", g.sqlserver.Update<Topic>(items).SetRaw("Title='test'").ExecuteUpdated().FirstOrDefault().Title);
Assert.Equal("test1", g.sqlserver.Update<Topic>(items).SetRaw("Title='test1'").ExecuteUpdated(a => new { a.Title }).FirstOrDefault().Title);
Assert.Equal("test2", g.sqlserver.Update<Topic>(items).SetRaw("Title='test2'").ExecuteUpdated(a => a.Title).FirstOrDefault());
items = g.sqlserver.Select<Topic>().Limit(2).ToList(); items = g.sqlserver.Select<Topic>().Limit(2).ToList();
var result = g.sqlserver.Update<Topic>(items).SetRaw("Title='test'").ExecuteUpdatedAsync().Result; Assert.Equal("test", g.sqlserver.Update<Topic>(items).SetRaw("Title='test'").ExecuteUpdatedAsync().Result.FirstOrDefault().Title);
} Assert.Equal("test1", g.sqlserver.Update<Topic>(items).SetRaw("Title='test1'").ExecuteUpdatedAsync(a => new { a.Title }).Result.FirstOrDefault().Title);
Assert.Equal("test2", g.sqlserver.Update<Topic>(items).SetRaw("Title='test2'").ExecuteUpdatedAsync(a => a.Title).Result.FirstOrDefault());
}
[Fact] [Fact]
public void AsTable() public void AsTable()

View File

@ -3570,6 +3570,83 @@
<param name="cmdText"></param> <param name="cmdText"></param>
<param name="cmdParms"></param> <param name="cmdParms"></param>
</member> </member>
<member name="M:FreeSql.IAdo.ExecuteScalar(System.String,System.Object)">
<summary>
在【主库】执行ExecuteScalar("select 1 from user where age > @age", new { age = 25 })<para></para>
提示parms 参数还可以传 Dictionary&lt;string, object&gt;
</summary>
<pa name="cmdType"></param>
<param name="cmdText"></param>
<param name="cmdParms"></param>
</member>
<member name="M:FreeSql.IAdo.ExecuteArray(System.String,System.Object)">
<summary>
查询ExecuteArray("select * from user where age > @age", new { age = 25 })<para></para>
提示parms 参数还可以传 Dictionary&lt;string, object&gt;
</summary>
<param name="cmdText"></param>
<param name="parms"></param>
<returns></returns>
</member>
<member name="M:FreeSql.IAdo.ExecuteDataSet(System.Data.CommandType,System.String,System.Data.Common.DbParameter[])">
<summary>
查询
</summary>
<param name="cmdType"></param>
<param name="cmdText"></param>
<param name="cmdParms"></param>
</member>
<member name="M:FreeSql.IAdo.ExecuteDataSet(System.String,System.Object)">
<summary>
查询ExecuteDataSet("select * from user where age > @age; select 2", new { age = 25 })<para></para>
提示parms 参数还可以传 Dictionary&lt;string, object&gt;
</summary>
<param name="cmdText"></param>
<param name="parms"></param>
<returns></returns>
</member>
<member name="M:FreeSql.IAdo.ExecuteDataTable(System.Data.CommandType,System.String,System.Data.Common.DbParameter[])">
<summary>
查询
</summary>
<param name="cmdType"></param>
<param name="cmdText"></param>
<param name="cmdParms"></param>
</member>
<member name="M:FreeSql.IAdo.ExecuteDataTable(System.String,System.Object)">
<summary>
查询ExecuteDataTable("select * from user where age > @age", new { age = 25 })<para></para>
提示parms 参数还可以传 Dictionary&lt;string, object&gt;
</summary>
<param name="cmdText"></param>
<param name="parms"></param>
<returns></returns>
</member>
<member name="M:FreeSql.IAdo.ExecuteNonQuery(System.Data.CommandType,System.String,System.Data.Common.DbParameter[])">
<summary>
在【主库】执行
</summary>
<param name="cmdType"></param>
<param name="cmdText"></param>
<param name="cmdParms"></param>
</member>
<member name="M:FreeSql.IAdo.ExecuteNonQuery(System.String,System.Object)">
<summary>
在【主库】执行ExecuteNonQuery("delete from user where age > @age", new { age = 25 })<para></para>
提示parms 参数还可以传 Dictionary&lt;string, object&gt;
</summary>
<param name="cmdText"></param>
<param name="parms"></param>
<returns></returns>
</member>
<member name="M:FreeSql.IAdo.ExecuteScalar(System.Data.CommandType,System.String,System.Data.Common.DbParameter[])">
<summary>
在【主库】执行
</summary>
<param name="cmdType"></param>
<param name="cmdText"></param>
<param name="cmdParms"></param>
</member>
<member name="M:FreeSql.IAdo.ExecuteScalar(System.String,System.Object)"> <member name="M:FreeSql.IAdo.ExecuteScalar(System.String,System.Object)">
<summary> <summary>
在【主库】执行ExecuteScalar("select 1 from user where age > @age", new { age = 25 })<para></para> 在【主库】执行ExecuteScalar("select 1 from user where age > @age", new { age = 25 })<para></para>
@ -5808,6 +5885,28 @@
请使用 fsql.InsertDict(dict) 方法插入字典数据 请使用 fsql.InsertDict(dict) 方法插入字典数据
</summary> </summary>
</member> </member>
<member name="M:FreeSqlGlobalDynamicEntityExtensions.DynamicEntity(FreeSql.ICodeFirst,System.String,System.Attribute[])">
<summary>
动态构建Class Type
</summary>
<returns></returns>
</member>
<member name="M:FreeSqlGlobalDynamicEntityExtensions.CreateInstance(FreeSql.Internal.Model.TableInfo,System.Collections.Generic.Dictionary{System.String,System.Object})">
<summary>
根据字典,创建 table 对应的实体对象
</summary>
<param name="table"></param>
<param name="dict"></param>
<returns></returns>
</member>
<member name="M:FreeSqlGlobalDynamicEntityExtensions.CreateDictionary(FreeSql.Internal.Model.TableInfo,System.Object)">
<summary>
根据实体对象,创建 table 对应的字典
</summary>
<param name="table"></param>
<param name="instance"></param>
<returns></returns>
</member>
<member name="M:FreeSqlGlobalExpressionCallExtensions.Between(System.DateTime,System.DateTime,System.DateTime)"> <member name="M:FreeSqlGlobalExpressionCallExtensions.Between(System.DateTime,System.DateTime,System.DateTime)">
<summary> <summary>
C# that >= between &amp;&amp; that &lt;= and<para></para> C# that >= between &amp;&amp; that &lt;= and<para></para>

View File

@ -479,10 +479,10 @@ namespace FreeSql.Internal.CommonProvider
public List<T1> ExecuteUpdated() => ExecuteUpdated<T1>(_table.ColumnsByPosition); public List<T1> ExecuteUpdated() => ExecuteUpdated<T1>(_table.ColumnsByPosition);
public List<TReturn> ExecuteUpdated<TReturn>(Expression<Func<T1, TReturn>> returnColumns) public List<TReturn> ExecuteUpdated<TReturn>(Expression<Func<T1, TReturn>> returnColumns)
{ {
var cols = new List<SelectColumnInfo>(); var cols = _commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, null, returnColumns?.Body, false, null)
_commonExpression.ExpressionSelectColumn_MemberAccess(null, null, cols, SelectTableInfoType.From, returnColumns?.Body, true, null); .Distinct().Select(a => _table.ColumnsByCs.TryGetValue(a, out var c) ? c : null).Where(a => a != null).ToArray();
return ExecuteUpdated<TReturn>(cols.Select(a => a.Column)); return ExecuteUpdated<TReturn>(cols);
} }
public IUpdate<T1> IgnoreColumns(Expression<Func<T1, object>> columns) => IgnoreColumns(_commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, null, columns?.Body, false, null)); public IUpdate<T1> IgnoreColumns(Expression<Func<T1, object>> columns) => IgnoreColumns(_commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, null, columns?.Body, false, null));

View File

@ -90,7 +90,7 @@ namespace FreeSql.Internal.CommonProvider
ClearData(); ClearData();
} }
async protected virtual Task<int> SplitExecuteAffrowsAsync(int valuesLimit, int parameterLimit, CancellationToken cancellationToken = default) async protected Task<int> SplitExecuteAffrowsAsync(int valuesLimit, int parameterLimit, CancellationToken cancellationToken = default)
{ {
var ret = 0; var ret = 0;
await SplitExecuteAsync(valuesLimit, parameterLimit, "SplitExecuteAffrowsAsync", async () => await SplitExecuteAsync(valuesLimit, parameterLimit, "SplitExecuteAffrowsAsync", async () =>
@ -98,7 +98,7 @@ namespace FreeSql.Internal.CommonProvider
); );
return ret; return ret;
} }
async protected virtual Task<List<TReturn>> SplitExecuteUpdatedAsync<TReturn>(int valuesLimit, int parameterLimit, IEnumerable<ColumnInfo> columns, CancellationToken cancellationToken = default) async protected Task<List<TReturn>> SplitExecuteUpdatedAsync<TReturn>(int valuesLimit, int parameterLimit, IEnumerable<ColumnInfo> columns, CancellationToken cancellationToken = default)
{ {
var ret = new List<TReturn>(); var ret = new List<TReturn>();
await SplitExecuteAsync(valuesLimit, parameterLimit, "SplitExecuteUpdatedAsync", async () => await SplitExecuteAsync(valuesLimit, parameterLimit, "SplitExecuteUpdatedAsync", async () =>
@ -146,9 +146,9 @@ namespace FreeSql.Internal.CommonProvider
public Task<List<T1>> ExecuteUpdatedAsync(CancellationToken cancellationToken = default) => ExecuteUpdatedAsync<T1>(_table.ColumnsByPosition, cancellationToken); public Task<List<T1>> ExecuteUpdatedAsync(CancellationToken cancellationToken = default) => ExecuteUpdatedAsync<T1>(_table.ColumnsByPosition, cancellationToken);
public Task<List<TReturn>> ExecuteUpdatedAsync<TReturn>(Expression<Func<T1, TReturn>> returnColumns, CancellationToken cancellationToken = default) public Task<List<TReturn>> ExecuteUpdatedAsync<TReturn>(Expression<Func<T1, TReturn>> returnColumns, CancellationToken cancellationToken = default)
{ {
var cols = new List<SelectColumnInfo>(); var cols = _commonExpression.ExpressionSelectColumns_MemberAccess_New_NewArrayInit(null, null, returnColumns?.Body, false, null)
_commonExpression.ExpressionSelectColumn_MemberAccess(null, null, cols, SelectTableInfoType.From, returnColumns?.Body, true, null); .Distinct().Select(a => _table.ColumnsByCs.TryGetValue(a, out var c) ? c : null).Where(a => a != null).ToArray();
return ExecuteUpdatedAsync<TReturn>(cols.Select(a => a.Column), cancellationToken); return ExecuteUpdatedAsync<TReturn>(cols, cancellationToken);
} }
#endif #endif
} }

View File

@ -58,7 +58,8 @@ namespace FreeSql.Custom.MySql
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
@ -146,9 +147,10 @@ namespace FreeSql.Custom.MySql
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -59,7 +59,8 @@ namespace FreeSql.Custom.PostgreSQL
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
@ -163,9 +164,10 @@ namespace FreeSql.Custom.PostgreSQL
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -57,7 +57,8 @@ namespace FreeSql.Custom.SqlServer
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
@ -149,9 +150,10 @@ namespace FreeSql.Custom.SqlServer
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -50,9 +50,10 @@ namespace FreeSql.Firebird.Curd
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
catch (Exception ex) catch (Exception ex)
@ -139,9 +140,10 @@ namespace FreeSql.Firebird.Curd
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -59,7 +59,8 @@ namespace FreeSql.KingbaseES
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
@ -164,7 +165,8 @@ namespace FreeSql.KingbaseES
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }

View File

@ -57,9 +57,10 @@ namespace FreeSql.MySql.Curd
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
catch (Exception ex) catch (Exception ex)
@ -146,9 +147,10 @@ namespace FreeSql.MySql.Curd
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -59,7 +59,8 @@ namespace FreeSql.Odbc.KingbaseES
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
@ -164,7 +165,8 @@ namespace FreeSql.Odbc.KingbaseES
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }

View File

@ -58,7 +58,8 @@ namespace FreeSql.Odbc.MySql
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
@ -147,7 +148,8 @@ namespace FreeSql.Odbc.MySql
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }

View File

@ -59,7 +59,8 @@ namespace FreeSql.Odbc.PostgreSQL
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
@ -164,7 +165,8 @@ namespace FreeSql.Odbc.PostgreSQL
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }

View File

@ -57,7 +57,8 @@ namespace FreeSql.Odbc.SqlServer
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
@ -150,7 +151,8 @@ namespace FreeSql.Odbc.SqlServer
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }

View File

@ -58,9 +58,10 @@ namespace FreeSql.PostgreSQL.Curd
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
catch (Exception ex) catch (Exception ex)
@ -163,9 +164,10 @@ namespace FreeSql.PostgreSQL.Curd
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -94,10 +94,10 @@ namespace FreeSql.QuestDb.Curd
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
CommandType.Text, sql, _commandTimeout, dbParms); var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
catch (Exception ex) catch (Exception ex)
@ -219,10 +219,10 @@ namespace FreeSql.QuestDb.Curd
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
_transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -60,7 +60,8 @@ namespace FreeSql.ShenTong.Curd
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
@ -165,7 +166,8 @@ namespace FreeSql.ShenTong.Curd
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }

View File

@ -57,7 +57,8 @@ namespace FreeSql.SqlServer.Curd
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
@ -149,9 +150,10 @@ namespace FreeSql.SqlServer.Curd
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -58,9 +58,10 @@ namespace FreeSql.Xugu.Curd
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = _orm.Ado.Query<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }
catch (Exception ex) catch (Exception ex)
@ -149,8 +150,9 @@ namespace FreeSql.Xugu.Curd
Exception exception = null; Exception exception = null;
try try
{ {
var rettmp = await _orm.Ado.QueryAsync<TReturn>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken); var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
ValidateVersionAndThrow(rettmp.Count, sql, dbParms); ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
ret.AddRange(rettmp); ret.AddRange(rettmp);
} }