From 1fc2a1c0a1716ac9417ed9af035cb4e71a35af28 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sat, 3 Jun 2023 12:21:20 +0800 Subject: [PATCH] Update exp to sql --- .../SqlSugar/ExpressionsToSql/Subquery/Items/SubFirst.cs | 5 ++++- .../SqlSugar/ExpressionsToSql/Subquery/Items/SubToList.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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;