From 629cb49c9f5b7013b63ccd88c31220de824c0224 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sat, 21 May 2022 18:47:41 +0800 Subject: [PATCH] Update exp to sql --- .../ResolveItems/OneToManyNavgateExpression.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/OneToManyNavgateExpression.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/OneToManyNavgateExpression.cs index e5c80b005..d2be90c91 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/OneToManyNavgateExpression.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/OneToManyNavgateExpression.cs @@ -123,13 +123,20 @@ namespace SqlSugar mappingA = queryable.QueryBuilder.Builder.GetTranslationColumnName(mappingA); mappingB = queryable.QueryBuilder.Builder.GetTranslationColumnName(mappingB); var bTableName = queryable.QueryBuilder.Builder.GetTranslationTableName(this.ProPertyEntity.DbTableName); - mapper.Sql = $" (select count(1) from {bTableName} {this.ProPertyEntity.DbTableName}_1 where {this.ProPertyEntity.DbTableName}_1.{bPk} in (select {mappingB} from {mappingTableName} where {mappingA} = {ShorName}.{aPk} ) )"; + mapper.Sql = $" (select {(MethodName == "Any" ? "1":" COUNT(1) ")} from {bTableName} {this.ProPertyEntity.DbTableName}_1 where {this.ProPertyEntity.DbTableName}_1.{bPk} in (select {mappingB} from {mappingTableName} where {mappingA} = {ShorName}.{aPk} ) )"; if (this.whereSql.HasValue()) { mapper.Sql = mapper.Sql.TrimEnd(')'); mapper.Sql = mapper.Sql + " AND " + this.whereSql+")"; } - mapper.Sql = $" ({mapper.Sql}) "; + if (MethodName == "Any") + { + mapper.Sql = $" {mapper.Sql} "; + } + else + { + mapper.Sql = $" ({mapper.Sql}) "; + } mapper.Sql = GetMethodSql(mapper.Sql); return mapper; }