mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-17 05:29:33 +08:00
Update Select<Interface>().ToList()
This commit is contained in:
parent
3dd211d3f2
commit
2f6c60885c
@ -10,7 +10,7 @@ using System.Reflection;
|
||||
using System.Dynamic;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
|
||||
@ -853,6 +853,11 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual string ToSqlString()
|
||||
{
|
||||
if (this.EntityInfo?.Type?.IsInterface==true)
|
||||
{
|
||||
this.QueryBuilder.SelectValue = " * ";
|
||||
this.AsType(this.EntityInfo.Type);
|
||||
}
|
||||
var sqlObj = this.Clone().ToSql();
|
||||
var result = sqlObj.Key;
|
||||
if (result == null) return null;
|
||||
|
@ -329,7 +329,7 @@ namespace SqlSugar
|
||||
}
|
||||
public ISugarQueryable<T> Clone()
|
||||
{
|
||||
var queryable = this.Context.Queryable<object>().Select<T>().WithCacheIF(IsCache, CacheTime);
|
||||
var queryable = this.Context.Queryable<object>().AsType(this.QueryBuilder.AsType).Select<T>().WithCacheIF(IsCache, CacheTime);
|
||||
CopyQueryBuilder(queryable.QueryBuilder);
|
||||
((QueryableProvider<T>)queryable).CacheKey = this.CacheKey;
|
||||
((QueryableProvider<T>)queryable).MapperAction = this.MapperAction;
|
||||
@ -361,6 +361,10 @@ namespace SqlSugar
|
||||
}
|
||||
public ISugarQueryable<T> AsType(Type tableNameType)
|
||||
{
|
||||
if (tableNameType == null)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
this.QueryBuilder.AsType = tableNameType;
|
||||
return AS(this.Context.EntityMaintenance.GetEntityInfo(tableNameType).DbTableName);
|
||||
}
|
||||
@ -1526,6 +1530,13 @@ namespace SqlSugar
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeof(TResult).IsInterface&& typeof(TResult).IsAssignableFrom(this.EntityInfo.Type))
|
||||
{
|
||||
if (!this.QueryBuilder.AsTables.Any())
|
||||
{
|
||||
this.AsType(this.EntityInfo.Type);
|
||||
}
|
||||
}
|
||||
var selects = this.QueryBuilder.GetSelectValueByString();
|
||||
if (selects.ObjToString().ToLower().IsContainsIn(".","("," as "))
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
<package >
|
||||
<metadata>
|
||||
<id>SqlSugarCore</id>
|
||||
<version>5.1.4.175</version>
|
||||
<version>5.1.4.176-preview03</version>
|
||||
<authors>sunkaixuan</authors>
|
||||
<owners>果糖大数据科技</owners>
|
||||
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
||||
|
Loading…
Reference in New Issue
Block a user