mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-02 20:02:47 +08:00
Synchronization code
This commit is contained in:
parent
75e6285a54
commit
fe2d7f4f99
@ -657,12 +657,18 @@ namespace SqlSugar
|
||||
{
|
||||
shortName = this.Builder.GetTranslationColumnName(shortName);
|
||||
}
|
||||
return string.Format(
|
||||
var result= string.Format(
|
||||
this.JoinTemplate,
|
||||
joinInfo.JoinType.ToString() + UtilConstants.Space,
|
||||
Builder.GetTranslationTableName(name) + UtilConstants.Space,
|
||||
shortName + UtilConstants.Space + (TableWithString == SqlWith.Null|| isSubQuery ? " " : TableWithString),
|
||||
joinInfo.JoinWhere);
|
||||
if (joinInfo.EntityType!=null&&this.Context.EntityMaintenance.GetEntityInfoWithAttr(joinInfo.EntityType).Discrimator.HasValue())
|
||||
{
|
||||
var entityInfo = this.Context.EntityMaintenance.GetEntityInfoWithAttr(joinInfo.EntityType);
|
||||
result = $" {result} AND {shortName}.{UtilMethods.GetDiscrimator(entityInfo,this.Builder)}";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public virtual void Clear()
|
||||
{
|
||||
|
@ -1312,6 +1312,22 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
}
|
||||
internal static string GetDiscrimator(EntityInfo entityInfo,ISqlBuilder builer)
|
||||
{
|
||||
List<string> wheres = new List<string>();
|
||||
if (entityInfo != null && entityInfo.Discrimator.HasValue())
|
||||
{
|
||||
Check.ExceptionEasy(!Regex.IsMatch(entityInfo.Discrimator, @"^(?:\w+:\w+)(?:,\w+:\w+)*$"), "The format should be type:cat for this type, and if there are multiple, it can be FieldName:cat,FieldName2:dog ", "格式错误应该是type:cat这种格式,如果是多个可以FieldName:cat,FieldName2:dog,不要有空格");
|
||||
var array = entityInfo.Discrimator.Split(',');
|
||||
foreach (var disItem in array)
|
||||
{
|
||||
var name = disItem.Split(':').First();
|
||||
var value = disItem.Split(':').Last();
|
||||
wheres.Add($"{builer.GetTranslationColumnName(name)}={value.ToSqlValue()} ");
|
||||
}
|
||||
}
|
||||
return string.Join(" AND ", wheres);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user