Optimized code select dto

This commit is contained in:
sunkaixuna
2021-10-31 08:42:40 +08:00
parent 6456c0c698
commit c74b6c2381
2 changed files with 7 additions and 2 deletions

View File

@@ -169,6 +169,7 @@ namespace OrmTest
.Select(it=>new ViewOrder(){ .Select(it=>new ViewOrder(){
Name=SqlFunc.Subqueryable<Order>().Select(s=>s.Name) Name=SqlFunc.Subqueryable<Order>().Select(s=>s.Name)
}).ToList(); }).ToList();
var test19 = db.Queryable<Order>().Select<ViewOrder>().ToList();
Console.WriteLine("#### Examples End ####"); Console.WriteLine("#### Examples End ####");
} }

View File

@@ -790,10 +790,14 @@ namespace SqlSugar
var selectValue = new SugarMapper(this.Context).GetSelectValue<TResult>(this.QueryBuilder); var selectValue = new SugarMapper(this.Context).GetSelectValue<TResult>(this.QueryBuilder);
return this.Select<TResult>(selectValue); return this.Select<TResult>(selectValue);
} }
else if (this.QueryBuilder.EntityType == UtilConstants.ObjType || (this.QueryBuilder.AsTables != null && this.QueryBuilder.AsTables.Count == 1)||this.QueryBuilder.EntityName!=this.QueryBuilder.EntityType.Name)
{
return this.Select<TResult>(this.SqlBuilder.SqlSelectAll);
}
else else
{ {
var selects = this.QueryBuilder.GetSelectValueByString();
return this.Select<TResult>(this.SqlBuilder.SqlSelectAll); return this.Select<TResult>(selects);
} }
} }