Browse Source

Optimized code select dto

pull/9/head
sunkaixuna 3 years ago
parent
commit
c74b6c2381
  1. 1
      Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs
  2. 8
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

1
Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs

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

8
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -790,11 +790,15 @@ namespace SqlSugar
var selectValue = new SugarMapper(this.Context).GetSelectValue<TResult>(this.QueryBuilder);
return this.Select<TResult>(selectValue);
}
else
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
{
var selects = this.QueryBuilder.GetSelectValueByString();
return this.Select<TResult>(selects);
}
}
public virtual ISugarQueryable<TResult> Select<TResult>(string selectValue)

Loading…
Cancel
Save