mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-18 17:48:11 +08:00
-
This commit is contained in:
@@ -12,10 +12,12 @@ namespace OrmTest.UnitTest
|
||||
{
|
||||
public void Init()
|
||||
{
|
||||
using (var db = GetInstance())
|
||||
var db = GetInstance();
|
||||
for (int i = 0; i < 200; i++)
|
||||
{
|
||||
var x= db.Queryable<Student>().ToList();
|
||||
var x = db.Queryable<Student>().ToList();
|
||||
}
|
||||
|
||||
}
|
||||
public SqlSugarClient GetInstance()
|
||||
{
|
||||
|
@@ -173,6 +173,7 @@ namespace SqlSugar
|
||||
{
|
||||
this.Transaction.Commit();
|
||||
this.Transaction = null;
|
||||
if (this.Context.CurrentConnectionConfig.IsAutoCloseConnection) this.Close();
|
||||
}
|
||||
}
|
||||
public virtual void CommitTran()
|
||||
@@ -181,6 +182,7 @@ namespace SqlSugar
|
||||
{
|
||||
this.Transaction.Commit();
|
||||
this.Transaction = null;
|
||||
if (this.Context.CurrentConnectionConfig.IsAutoCloseConnection) this.Close();
|
||||
}
|
||||
}
|
||||
public abstract IDataParameter[] ToIDbDataParameter(params SugarParameter[] pars);
|
||||
@@ -201,6 +203,7 @@ namespace SqlSugar
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecLogEvent(sql, pars, false);
|
||||
if (this.Context.CurrentConnectionConfig.IsAutoCloseConnection&&this.Transaction==null) this.Close();
|
||||
return count;
|
||||
}
|
||||
public virtual IDataReader GetDataReader(string sql, params SugarParameter[] pars)
|
||||
@@ -226,6 +229,7 @@ namespace SqlSugar
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecLogEvent(sql, pars, false);
|
||||
if (this.Context.CurrentConnectionConfig.IsAutoCloseConnection && this.Transaction == null) this.Close();
|
||||
return ds;
|
||||
}
|
||||
public virtual object GetScalar(string sql, params SugarParameter[] pars)
|
||||
@@ -238,6 +242,7 @@ namespace SqlSugar
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecLogEvent(sql, pars, false);
|
||||
if (this.Context.CurrentConnectionConfig.IsAutoCloseConnection && this.Transaction == null) this.Close();
|
||||
return scalar;
|
||||
}
|
||||
#endregion
|
||||
|
@@ -587,6 +587,7 @@ namespace SqlSugar
|
||||
}
|
||||
private List<TResult> _ToList<TResult>()
|
||||
{
|
||||
List<TResult> result = null;
|
||||
var sqlObj = this.ToSql();
|
||||
var isComplexModel = QueryBuilder.IsComplexModel(sqlObj.Key);
|
||||
using (var dataReader = this.Db.GetDataReader(sqlObj.Key, sqlObj.Value.ToArray()))
|
||||
@@ -594,14 +595,15 @@ namespace SqlSugar
|
||||
var tType = typeof(TResult);
|
||||
if (tType.IsAnonymousType() || isComplexModel)
|
||||
{
|
||||
return this.Context.RewritableMethods.DataReaderToDynamicList<TResult>(dataReader);
|
||||
result= this.Context.RewritableMethods.DataReaderToDynamicList<TResult>(dataReader);
|
||||
}
|
||||
else
|
||||
{
|
||||
var reval = this.Bind.DataReaderToList<TResult>(tType, dataReader, QueryBuilder.SelectCacheKey);
|
||||
return reval;
|
||||
}
|
||||
if (this.Context.CurrentConnectionConfig.IsAutoCloseConnection) this.Context.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@@ -230,6 +230,7 @@ namespace SqlSugar
|
||||
using (var dataReader = this.Database.GetDataReader(sql, dbPars))
|
||||
{
|
||||
var reval = this.Database.DbBind.DataReaderToList<T>(typeof(T), dataReader, builder.SqlQueryBuilder.Fields);
|
||||
if (this.CurrentConnectionConfig.IsAutoCloseConnection) this.Close();
|
||||
builder.SqlQueryBuilder.Clear();
|
||||
return reval;
|
||||
}
|
||||
|
Reference in New Issue
Block a user