mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-19 22:49:35 +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.Dynamic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Newtonsoft.Json.Serialization;
|
using Newtonsoft.Json.Serialization;
|
||||||
|
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -853,6 +853,11 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public virtual string ToSqlString()
|
public virtual string ToSqlString()
|
||||||
{
|
{
|
||||||
|
if (this.EntityInfo?.Type?.IsInterface==true)
|
||||||
|
{
|
||||||
|
this.QueryBuilder.SelectValue = " * ";
|
||||||
|
this.AsType(this.EntityInfo.Type);
|
||||||
|
}
|
||||||
var sqlObj = this.Clone().ToSql();
|
var sqlObj = this.Clone().ToSql();
|
||||||
var result = sqlObj.Key;
|
var result = sqlObj.Key;
|
||||||
if (result == null) return null;
|
if (result == null) return null;
|
||||||
|
@ -329,7 +329,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public ISugarQueryable<T> Clone()
|
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);
|
CopyQueryBuilder(queryable.QueryBuilder);
|
||||||
((QueryableProvider<T>)queryable).CacheKey = this.CacheKey;
|
((QueryableProvider<T>)queryable).CacheKey = this.CacheKey;
|
||||||
((QueryableProvider<T>)queryable).MapperAction = this.MapperAction;
|
((QueryableProvider<T>)queryable).MapperAction = this.MapperAction;
|
||||||
@ -361,6 +361,10 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public ISugarQueryable<T> AsType(Type tableNameType)
|
public ISugarQueryable<T> AsType(Type tableNameType)
|
||||||
{
|
{
|
||||||
|
if (tableNameType == null)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
this.QueryBuilder.AsType = tableNameType;
|
this.QueryBuilder.AsType = tableNameType;
|
||||||
return AS(this.Context.EntityMaintenance.GetEntityInfo(tableNameType).DbTableName);
|
return AS(this.Context.EntityMaintenance.GetEntityInfo(tableNameType).DbTableName);
|
||||||
}
|
}
|
||||||
@ -1526,6 +1530,13 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
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();
|
var selects = this.QueryBuilder.GetSelectValueByString();
|
||||||
if (selects.ObjToString().ToLower().IsContainsIn(".","("," as "))
|
if (selects.ObjToString().ToLower().IsContainsIn(".","("," as "))
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>SqlSugarCore</id>
|
<id>SqlSugarCore</id>
|
||||||
<version>5.1.4.175</version>
|
<version>5.1.4.176-preview03</version>
|
||||||
<authors>sunkaixuan</authors>
|
<authors>sunkaixuan</authors>
|
||||||
<owners>果糖大数据科技</owners>
|
<owners>果糖大数据科技</owners>
|
||||||
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
||||||
|
Loading…
Reference in New Issue
Block a user