Browse Source

Update filter bug

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

17
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);
if (ChildType.IsInterface)
{
foreach (var joinInfoItem in this.JoinQueryInfos.Where(it => it.EntityType.GetInterfaces().Any(z=>z==ChildType)))
{
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)) foreach (var joinInfoItem in this.JoinQueryInfos.Where(it => it.TableName == entityInfo.DbTableName))
{ {
var addSql = mysql.Replace(itName, this.Builder.GetTranslationColumnName(joinInfoItem.ShortName)+"."); var addSql = mysql.Replace(itName, this.Builder.GetTranslationColumnName(joinInfoItem.ShortName) + ".");
joinInfoItem.JoinWhere+= (" AND "+Regex.Replace(addSql,"^ (WHERE|AND) ","")); 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