mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-08 18:34:55 +08:00
Support Select<Object> (*)
This commit is contained in:
@@ -476,6 +476,7 @@ namespace OrmTest.Demo
|
|||||||
var s2 = db.Queryable<Student>().Select(it => new { id = it.Id, w = new { x = it } }).ToList();
|
var s2 = db.Queryable<Student>().Select(it => new { id = it.Id, w = new { x = it } }).ToList();
|
||||||
var s3 = db.Queryable<Student>().Select(it => new { newid = it.Id }).ToList();
|
var s3 = db.Queryable<Student>().Select(it => new { newid = it.Id }).ToList();
|
||||||
var s4 = db.Queryable<Student>().Select(it => new { newid = it.Id, obj = it }).ToList();
|
var s4 = db.Queryable<Student>().Select(it => new { newid = it.Id, obj = it }).ToList();
|
||||||
|
var s41 = db.Queryable<Student>().Select<dynamic>("*").ToList();
|
||||||
var s5 = db.Queryable<Student>().Select(it => new ViewModelStudent2 { Student = it, Name = it.Name }).ToList();
|
var s5 = db.Queryable<Student>().Select(it => new ViewModelStudent2 { Student = it, Name = it.Name }).ToList();
|
||||||
var s6 = db.Queryable<Student, School>((st, sc) => new object[] {
|
var s6 = db.Queryable<Student, School>((st, sc) => new object[] {
|
||||||
JoinType.Left,st.SchoolId==sc.Id
|
JoinType.Left,st.SchoolId==sc.Id
|
||||||
|
|||||||
@@ -1071,10 +1071,14 @@ namespace SqlSugar
|
|||||||
var isComplexModel = QueryBuilder.IsComplexModel(sqlObj.Key);
|
var isComplexModel = QueryBuilder.IsComplexModel(sqlObj.Key);
|
||||||
var entityType = typeof(TResult);
|
var entityType = typeof(TResult);
|
||||||
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))
|
if (entityType == UtilConstants.DynamicType)
|
||||||
{
|
{
|
||||||
result = this.Context.Utilities.DataReaderToExpandoObjectList(dataReader) as List<TResult>;
|
result = this.Context.Utilities.DataReaderToExpandoObjectList(dataReader) as List<TResult>;
|
||||||
}
|
}
|
||||||
|
else if (entityType == UtilConstants.ObjType)
|
||||||
|
{
|
||||||
|
result = this.Context.Utilities.DataReaderToExpandoObjectList(dataReader).Select(it => ((TResult)(object)it)).ToList();
|
||||||
|
}
|
||||||
else if (entityType.IsAnonymousType() || isComplexModel)
|
else if (entityType.IsAnonymousType() || isComplexModel)
|
||||||
{
|
{
|
||||||
result = this.Context.Utilities.DataReaderToDynamicList<TResult>(dataReader);
|
result = this.Context.Utilities.DataReaderToDynamicList<TResult>(dataReader);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Dynamic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
@@ -27,6 +28,7 @@ namespace SqlSugar
|
|||||||
internal static Type DateType = typeof(DateTime);
|
internal static Type DateType = typeof(DateTime);
|
||||||
internal static Type ByteArrayType = typeof(byte[]);
|
internal static Type ByteArrayType = typeof(byte[]);
|
||||||
internal static Type ModelType= typeof(ModelContext);
|
internal static Type ModelType= typeof(ModelContext);
|
||||||
|
internal static Type DynamicType = typeof(ExpandoObject);
|
||||||
internal static Type Dicii = typeof(KeyValuePair<int, int>);
|
internal static Type Dicii = typeof(KeyValuePair<int, int>);
|
||||||
internal static Type DicIS = typeof(KeyValuePair<int, string>);
|
internal static Type DicIS = typeof(KeyValuePair<int, string>);
|
||||||
internal static Type DicSi = typeof(KeyValuePair<string, int>);
|
internal static Type DicSi = typeof(KeyValuePair<string, int>);
|
||||||
|
|||||||
Reference in New Issue
Block a user