diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubFirst.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubFirst.cs index af3cd4c45..a41ce1718 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubFirst.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubFirst.cs @@ -141,7 +141,10 @@ namespace SqlSugar var newMemExp = (bodyExp as MemberInitExpression); var parameters = ExpressionTool.GetParameters(exp); InitType(exp); - SetShortName(exp, null); + if (parameters.Any()) + { + this.Context.CurrentShortName = this.Context.GetTranslationColumnName(parameters.FirstOrDefault().Name); + } Check.ExceptionEasy(newMemExp == null, $"Subquery ToList(exp,true) expression {exp.ToString()} can only be it=>new class(){{Id = it.id}}", $"子查询ToList(exp,true)表达式{exp.ToString()}只能是it=>new class(){{ id=it.Id}}"); var dic = ExpressionTool.GetMemberBindingItemList(newMemExp.Bindings); var db = this.Context.SugarContext.Context; diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubToList.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubToList.cs index df67e136b..875708c76 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubToList.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Subquery/Items/SubToList.cs @@ -141,7 +141,10 @@ namespace SqlSugar var newMemExp = (bodyExp as MemberInitExpression); var parameters = ExpressionTool.GetParameters(exp); InitType(exp); - SetShortName(exp, null); + if (parameters.Any()) + { + this.Context.CurrentShortName = this.Context.GetTranslationColumnName(parameters.FirstOrDefault().Name); + } Check.ExceptionEasy(newMemExp == null, $"Subquery ToList(exp,true) expression {exp.ToString()} can only be it=>new class(){{Id = it.id}}", $"子查询ToList(exp,true)表达式{exp.ToString()}只能是it=>new class(){{ id=it.Id}}"); var dic=ExpressionTool.GetMemberBindingItemList(newMemExp.Bindings); var db = this.Context.SugarContext.Context;