From f01064b0c96b94e69d75bf0b3a29180cc83ee2d3 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 29 Sep 2017 13:43:51 +0800 Subject: [PATCH] - --- .../QueryableProvider/QueryableProvider.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index 50daac5c2..0cf6c1225 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -1008,13 +1008,23 @@ namespace SqlSugar var sqlObj = this.ToSql(); var isComplexModel = QueryBuilder.IsComplexModel(sqlObj.Key); var entityType = typeof(TResult); + result = GetData(sqlObj, isComplexModel, entityType); + RestoreMapping(); + SetContextModel(result, entityType); + return result; + } + + protected List GetData(KeyValuePair> sqlObj, bool isComplexModel, Type entityType) + { + List result; using (var dataReader = this.Db.GetDataReader(sqlObj.Key, sqlObj.Value.ToArray())) { if (typeof(TResult) == typeof(ExpandoObject)) { - result= this.Context.Utilities.DataReaderToExpandoObjectList(dataReader) as List; + result = this.Context.Utilities.DataReaderToExpandoObjectList(dataReader) as List; - }else if (entityType.IsAnonymousType() || isComplexModel) + } + else if (entityType.IsAnonymousType() || isComplexModel) { result = this.Context.Utilities.DataReaderToDynamicList(dataReader); } @@ -1023,10 +1033,10 @@ namespace SqlSugar result = this.Bind.DataReaderToList(entityType, dataReader, QueryBuilder.SelectCacheKey); } } - RestoreMapping(); - SetContextModel(result, entityType); + return result; } + protected void _InQueryable(Expression> expression, KeyValuePair> sqlObj) { string sql = sqlObj.Key;