mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-08 10:24:55 +08:00
-
This commit is contained in:
@@ -1017,12 +1017,10 @@ namespace SqlSugar
|
||||
protected List<TResult> GetData<TResult>(KeyValuePair<string, List<SugarParameter>> sqlObj, bool isComplexModel, Type entityType)
|
||||
{
|
||||
List<TResult> result;
|
||||
using (var dataReader = this.Db.GetDataReader(sqlObj.Key, sqlObj.Value.ToArray()))
|
||||
{
|
||||
var dataReader = this.Db.GetDataReader(sqlObj.Key, sqlObj.Value.ToArray());
|
||||
if (typeof(TResult) == typeof(ExpandoObject))
|
||||
{
|
||||
result = this.Context.Utilities.DataReaderToExpandoObjectList(dataReader) as List<TResult>;
|
||||
|
||||
}
|
||||
else if (entityType.IsAnonymousType() || isComplexModel)
|
||||
{
|
||||
@@ -1032,7 +1030,6 @@ namespace SqlSugar
|
||||
{
|
||||
result = this.Bind.DataReaderToList<TResult>(entityType, dataReader, QueryBuilder.SelectCacheKey);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -4677,7 +4674,8 @@ namespace SqlSugar
|
||||
base.With(withString);
|
||||
return this;
|
||||
}
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithCache(int cacheDurationInSeconds=int.MaxValue) {
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||
{
|
||||
this.IsCache = true;
|
||||
this.CacheTime = cacheDurationInSeconds;
|
||||
return this;
|
||||
|
||||
@@ -45,6 +45,8 @@ namespace SqlSugar
|
||||
/// <param name="reader"></param>
|
||||
/// <returns></returns>
|
||||
public List<ExpandoObject> DataReaderToExpandoObjectList(IDataReader reader)
|
||||
{
|
||||
using (reader)
|
||||
{
|
||||
List<ExpandoObject> result = new List<ExpandoObject>();
|
||||
if (reader != null && !reader.IsClosed)
|
||||
@@ -56,6 +58,7 @@ namespace SqlSugar
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///DataReader to DataReaderToDictionary
|
||||
@@ -89,6 +92,8 @@ namespace SqlSugar
|
||||
/// <param name="reader"></param>
|
||||
/// <returns></returns>
|
||||
public List<T> DataReaderToDynamicList<T>(IDataReader reader)
|
||||
{
|
||||
using (reader)
|
||||
{
|
||||
var tType = typeof(T);
|
||||
var classProperties = tType.GetProperties().ToList();
|
||||
@@ -149,10 +154,10 @@ namespace SqlSugar
|
||||
var stringValue = SerializeObject(result);
|
||||
reval.Add((T)DeserializeObject<T>(stringValue));
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
return reval;
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, object> DataReaderToDynamicList_Part<T>(Dictionary<string, object> readerValues, PropertyInfo item, List<T> reval)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user