Browse Source

Update filter bug

pull/31/head
sunkaixuan 2 years ago
parent
commit
f7ec6703e7
  1. 19
      Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs

19
Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs

@ -437,13 +437,24 @@ namespace SqlSugar
return; return;
var isSameName =!isSingle&& this.JoinQueryInfos.Count(it => it.TableName == entityInfo.DbTableName)>0; var isSameName =!isSingle&& this.JoinQueryInfos.Count(it => it.TableName == entityInfo.DbTableName)>0;
if (isSameName) if (isSameName||ChildType.IsInterface)
{ {
var mysql = GetSql(exp, isSingle); var mysql = GetSql(exp, isSingle);
foreach (var joinInfoItem in this.JoinQueryInfos.Where(it => it.TableName == entityInfo.DbTableName)) if (ChildType.IsInterface)
{ {
var addSql = mysql.Replace(itName, this.Builder.GetTranslationColumnName(joinInfoItem.ShortName)+"."); foreach (var joinInfoItem in this.JoinQueryInfos.Where(it => it.EntityType.GetInterfaces().Any(z=>z==ChildType)))
joinInfoItem.JoinWhere+= (" AND "+Regex.Replace(addSql,"^ (WHERE|AND) ","")); {
var addSql = mysql.Replace(itName, this.Builder.GetTranslationColumnName(joinInfoItem.ShortName) + ".");
joinInfoItem.JoinWhere += (" AND " + Regex.Replace(addSql, "^ (WHERE|AND) ", ""));
}
}
else
{
foreach (var joinInfoItem in this.JoinQueryInfos.Where(it => it.TableName == entityInfo.DbTableName))
{
var addSql = mysql.Replace(itName, this.Builder.GetTranslationColumnName(joinInfoItem.ShortName) + ".");
joinInfoItem.JoinWhere += (" AND " + Regex.Replace(addSql, "^ (WHERE|AND) ", ""));
}
} }
sql = mysql.Replace(itName, this.Builder.GetTranslationColumnName(TableShortName) + "."); sql = mysql.Replace(itName, this.Builder.GetTranslationColumnName(TableShortName) + ".");
} }

Loading…
Cancel
Save