Code optimization

This commit is contained in:
610262374@qq.com
2019-06-10 11:42:36 +08:00
parent 34824235aa
commit 3f55223a04

View File

@@ -777,37 +777,37 @@ namespace SqlSugar
result = GetData<T>(typeof(T), dataReader); result = GetData<T>(typeof(T), dataReader);
} }
List<T2> result2 = null; List<T2> result2 = null;
if (dataReader.NextResult()) if (NextResult(dataReader))
{ {
this.Context.InitMappingInfo<T2>(); this.Context.InitMappingInfo<T2>();
result2 = GetData<T2>(typeof(T2), dataReader); result2 = GetData<T2>(typeof(T2), dataReader);
} }
List<T3> result3 = null; List<T3> result3 = null;
if (dataReader.NextResult()) if (NextResult(dataReader))
{ {
this.Context.InitMappingInfo<T3>(); this.Context.InitMappingInfo<T3>();
result3 = GetData<T3>(typeof(T3), dataReader); result3 = GetData<T3>(typeof(T3), dataReader);
} }
List<T4> result4 = null; List<T4> result4 = null;
if (dataReader.NextResult()) if (NextResult(dataReader))
{ {
this.Context.InitMappingInfo<T4>(); this.Context.InitMappingInfo<T4>();
result4 = GetData<T4>(typeof(T4), dataReader); result4 = GetData<T4>(typeof(T4), dataReader);
} }
List<T5> result5 = null; List<T5> result5 = null;
if (dataReader.NextResult()) if (NextResult(dataReader))
{ {
this.Context.InitMappingInfo<T5>(); this.Context.InitMappingInfo<T5>();
result5 = GetData<T5>(typeof(T5), dataReader); result5 = GetData<T5>(typeof(T5), dataReader);
} }
List<T6> result6 = null; List<T6> result6 = null;
if (dataReader.NextResult()) if (NextResult(dataReader))
{ {
this.Context.InitMappingInfo<T6>(); this.Context.InitMappingInfo<T6>();
result6 = GetData<T6>(typeof(T6), dataReader); result6 = GetData<T6>(typeof(T6), dataReader);
} }
List<T7> result7 = null; List<T7> result7 = null;
if (dataReader.NextResult()) if (NextResult(dataReader))
{ {
this.Context.InitMappingInfo<T7>(); this.Context.InitMappingInfo<T7>();
result7 = GetData<T7>(typeof(T7), dataReader); result7 = GetData<T7>(typeof(T7), dataReader);
@@ -828,7 +828,6 @@ namespace SqlSugar
return Tuple.Create<List<T>, List<T2>, List<T3>, List<T4>, List<T5>, List<T6>, List<T7>>(result, result2, result3, result4, result5, result6, result7); return Tuple.Create<List<T>, List<T2>, List<T3>, List<T4>, List<T5>, List<T6>, List<T7>>(result, result2, result3, result4, result5, result6, result7);
} }
} }
public virtual Task<List<T>> SqlQueryAsync<T>(string sql, object parameters = null) public virtual Task<List<T>> SqlQueryAsync<T>(string sql, object parameters = null)
{ {
var sugarParameters = this.GetParameters(parameters); var sugarParameters = this.GetParameters(parameters);
@@ -892,37 +891,37 @@ namespace SqlSugar
result =await GetDataAsync<T>(typeof(T), dataReader); result =await GetDataAsync<T>(typeof(T), dataReader);
} }
List<T2> result2 = null; List<T2> result2 = null;
if (dataReader.NextResult()) if (NextResult(dataReader))
{ {
this.Context.InitMappingInfo<T2>(); this.Context.InitMappingInfo<T2>();
result2 = await GetDataAsync<T2>(typeof(T2), dataReader); result2 = await GetDataAsync<T2>(typeof(T2), dataReader);
} }
List<T3> result3 = null; List<T3> result3 = null;
if (dataReader.NextResult()) if (NextResult(dataReader))
{ {
this.Context.InitMappingInfo<T3>(); this.Context.InitMappingInfo<T3>();
result3 = await GetDataAsync<T3>(typeof(T3), dataReader); result3 = await GetDataAsync<T3>(typeof(T3), dataReader);
} }
List<T4> result4 = null; List<T4> result4 = null;
if (dataReader.NextResult()) if (NextResult(dataReader))
{ {
this.Context.InitMappingInfo<T4>(); this.Context.InitMappingInfo<T4>();
result4 = await GetDataAsync<T4>(typeof(T4), dataReader); result4 = await GetDataAsync<T4>(typeof(T4), dataReader);
} }
List<T5> result5 = null; List<T5> result5 = null;
if (dataReader.NextResult()) if (NextResult(dataReader))
{ {
this.Context.InitMappingInfo<T5>(); this.Context.InitMappingInfo<T5>();
result5 = await GetDataAsync<T5>(typeof(T5), dataReader); result5 = await GetDataAsync<T5>(typeof(T5), dataReader);
} }
List<T6> result6 = null; List<T6> result6 = null;
if (dataReader.NextResult()) if (NextResult(dataReader))
{ {
this.Context.InitMappingInfo<T6>(); this.Context.InitMappingInfo<T6>();
result6 = await GetDataAsync<T6>(typeof(T6), dataReader); result6 = await GetDataAsync<T6>(typeof(T6), dataReader);
} }
List<T7> result7 = null; List<T7> result7 = null;
if (dataReader.NextResult()) if (NextResult(dataReader))
{ {
this.Context.InitMappingInfo<T7>(); this.Context.InitMappingInfo<T7>();
result7 = await GetDataAsync<T7>(typeof(T7), dataReader); result7 = await GetDataAsync<T7>(typeof(T7), dataReader);
@@ -1157,13 +1156,25 @@ namespace SqlSugar
//{ //{
// try // try
// { // {
// dataReader.NextResult(); // NextResult(dataReader);
// } // }
// catch // catch
// { // {
// // Check.Exception(true, ErrorMessage.GetThrowMessage("Please reduce the number of T. Save Queue Changes queries don't have so many results", "请减少T的数量SaveQueueChanges 查询没有这么多结果")); // // Check.Exception(true, ErrorMessage.GetThrowMessage("Please reduce the number of T. Save Queue Changes queries don't have so many results", "请减少T的数量SaveQueueChanges 查询没有这么多结果"));
// } // }
//} //}
private static bool NextResult(IDataReader dataReader)
{
try
{
return dataReader.NextResult();
}
catch
{
return false;
}
}
private void ExecuteProcessingSQL(ref string sql, SugarParameter[] parameters) private void ExecuteProcessingSQL(ref string sql, SugarParameter[] parameters)
{ {
var result = this.ProcessingEventStartingSQL(sql, parameters); var result = this.ProcessingEventStartingSQL(sql, parameters);