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
|
||||||
|
|||||||
@@ -460,7 +460,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result= GetCount();
|
result = GetCount();
|
||||||
}
|
}
|
||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
QueryBuilder.IsCount = false;
|
QueryBuilder.IsCount = false;
|
||||||
@@ -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);
|
||||||
@@ -1440,7 +1444,7 @@ namespace SqlSugar
|
|||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2,T3> OrderByIF(bool isOrderBy, string orderFileds)
|
public new ISugarQueryable<T, T2, T3> OrderByIF(bool isOrderBy, string orderFileds)
|
||||||
{
|
{
|
||||||
if (isOrderBy)
|
if (isOrderBy)
|
||||||
base.OrderBy(orderFileds);
|
base.OrderBy(orderFileds);
|
||||||
@@ -1458,7 +1462,7 @@ namespace SqlSugar
|
|||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3> OrderByIF(bool isOrderBy, Expression<Func<T, T2,T3, object>> expression, OrderByType type = OrderByType.Asc)
|
public ISugarQueryable<T, T2, T3> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
|
||||||
{
|
{
|
||||||
if (isOrderBy)
|
if (isOrderBy)
|
||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
@@ -1496,7 +1500,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2,T3> Where(List<ConditionalModel> conditionalModels)
|
public new ISugarQueryable<T, T2, T3> Where(List<ConditionalModel> conditionalModels)
|
||||||
{
|
{
|
||||||
base.Where(conditionalModels);
|
base.Where(conditionalModels);
|
||||||
return this;
|
return this;
|
||||||
@@ -1678,7 +1682,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2,T3,T4> Where(List<ConditionalModel> conditionalModels)
|
public new ISugarQueryable<T, T2, T3, T4> Where(List<ConditionalModel> conditionalModels)
|
||||||
{
|
{
|
||||||
base.Where(conditionalModels);
|
base.Where(conditionalModels);
|
||||||
return this;
|
return this;
|
||||||
@@ -1786,7 +1790,7 @@ namespace SqlSugar
|
|||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3,T4, object>> expression, OrderByType type = OrderByType.Asc)
|
public ISugarQueryable<T, T2, T3, T4> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
|
||||||
{
|
{
|
||||||
if (isOrderBy)
|
if (isOrderBy)
|
||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
@@ -1963,7 +1967,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4,T5> Where(List<ConditionalModel> conditionalModels)
|
public new ISugarQueryable<T, T2, T3, T4, T5> Where(List<ConditionalModel> conditionalModels)
|
||||||
{
|
{
|
||||||
base.Where(conditionalModels);
|
base.Where(conditionalModels);
|
||||||
return this;
|
return this;
|
||||||
@@ -2063,7 +2067,7 @@ namespace SqlSugar
|
|||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4,T5> OrderByIF(bool isOrderBy, string orderFileds)
|
public new ISugarQueryable<T, T2, T3, T4, T5> OrderByIF(bool isOrderBy, string orderFileds)
|
||||||
{
|
{
|
||||||
if (isOrderBy)
|
if (isOrderBy)
|
||||||
base.OrderBy(orderFileds);
|
base.OrderBy(orderFileds);
|
||||||
@@ -2093,7 +2097,7 @@ namespace SqlSugar
|
|||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ISugarQueryable<T, T2, T3, T4, T5> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4,T5, object>> expression, OrderByType type = OrderByType.Asc)
|
public ISugarQueryable<T, T2, T3, T4, T5> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc)
|
||||||
{
|
{
|
||||||
if (isOrderBy)
|
if (isOrderBy)
|
||||||
_OrderBy(expression, type);
|
_OrderBy(expression, type);
|
||||||
@@ -2280,7 +2284,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5,T6> Where(List<ConditionalModel> conditionalModels)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6> Where(List<ConditionalModel> conditionalModels)
|
||||||
{
|
{
|
||||||
base.Where(conditionalModels);
|
base.Where(conditionalModels);
|
||||||
return this;
|
return this;
|
||||||
@@ -2587,7 +2591,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6,T7> Where(List<ConditionalModel> conditionalModels)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Where(List<ConditionalModel> conditionalModels)
|
||||||
{
|
{
|
||||||
base.Where(conditionalModels);
|
base.Where(conditionalModels);
|
||||||
return this;
|
return this;
|
||||||
@@ -2921,7 +2925,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7,T8> Where(List<ConditionalModel> conditionalModels)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Where(List<ConditionalModel> conditionalModels)
|
||||||
{
|
{
|
||||||
base.Where(conditionalModels);
|
base.Where(conditionalModels);
|
||||||
return this;
|
return this;
|
||||||
@@ -3287,7 +3291,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> Where(List<ConditionalModel> conditionalModels)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(List<ConditionalModel> conditionalModels)
|
||||||
{
|
{
|
||||||
base.Where(conditionalModels);
|
base.Where(conditionalModels);
|
||||||
return this;
|
return this;
|
||||||
@@ -3665,7 +3669,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> Where(List<ConditionalModel> conditionalModels)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(List<ConditionalModel> conditionalModels)
|
||||||
{
|
{
|
||||||
base.Where(conditionalModels);
|
base.Where(conditionalModels);
|
||||||
return this;
|
return this;
|
||||||
@@ -4079,7 +4083,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> Where(List<ConditionalModel> conditionalModels)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(List<ConditionalModel> conditionalModels)
|
||||||
{
|
{
|
||||||
base.Where(conditionalModels);
|
base.Where(conditionalModels);
|
||||||
return this;
|
return this;
|
||||||
@@ -4505,7 +4509,7 @@ namespace SqlSugar
|
|||||||
_Where(expression);
|
_Where(expression);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> Where(List<ConditionalModel> conditionalModels)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(List<ConditionalModel> conditionalModels)
|
||||||
{
|
{
|
||||||
base.Where(conditionalModels);
|
base.Where(conditionalModels);
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -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