Browse Source

Update exp to sql

pull/19/head
sunkaixuan 3 years ago
parent
commit
629cb49c9f
  1. 9
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/OneToManyNavgateExpression.cs

9
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+")";
}
if (MethodName == "Any")
{
mapper.Sql = $" {mapper.Sql} ";
}
else
{
mapper.Sql = $" ({mapper.Sql}) ";
}
mapper.Sql = GetMethodSql(mapper.Sql);
return mapper;
}

Loading…
Cancel
Save