Update Discrimator Join

This commit is contained in:
sunkaixuan
2023-08-14 12:10:10 +08:00
parent fdb1b4d5ed
commit 11bc0099c4
4 changed files with 5 additions and 4 deletions

View File

@@ -528,7 +528,7 @@ namespace SqlSugar
}
public ISugarQueryable<T> Where(string fieldName, string conditionalType, object fieldValue)
{
string parameterName = fieldName+ this.QueryBuilder.WhereIndex;
string parameterName = fieldName.Replace(".","_")+ this.QueryBuilder.WhereIndex;
var whereSql = this.SqlBuilder.GetWhere(fieldName, conditionalType, this.QueryBuilder.WhereIndex);
this.Where(whereSql);
this.QueryBuilder.WhereIndex++;

View File

@@ -113,7 +113,7 @@ namespace SqlSugar
public string GetWhere(string fieldName,string conditionalType,int? parameterIndex=null)
{
return string.Format(" {0} {1} {2}{3} ",this.GetTranslationColumnName(fieldName),conditionalType,this.SqlParameterKeyWord,fieldName+ parameterIndex);
return string.Format(" {0} {1} {2}{3} ",this.GetTranslationColumnName(fieldName),conditionalType,this.SqlParameterKeyWord,fieldName.Replace(".","_")+ parameterIndex);
}
public virtual string GetUnionAllSql(List<string> sqlList)
{

View File

@@ -353,6 +353,7 @@ namespace SqlSugar
{
queryable.SqlBuilder.QueryBuilder.Parameters.AddRange(paramters);
}
UtilMethods.AddDiscrimator(typeof(T), queryable, queryable.QueryBuilder.TableShortName + ".");
}
protected void CreateEasyQueryJoin<T>(Expression joinExpression, Type[] types, ISugarQueryable<T> queryable)
{

View File

@@ -1342,7 +1342,7 @@ namespace SqlSugar
}
internal static void AddDiscrimator<T>(Type type, ISugarQueryable<T> queryable)
internal static void AddDiscrimator<T>(Type type, ISugarQueryable<T> queryable,string shortName=null)
{
var entityInfo = queryable.Context?.EntityMaintenance?.GetEntityInfoWithAttr(type);
if (entityInfo!=null&&entityInfo.Discrimator.HasValue())
@@ -1353,7 +1353,7 @@ namespace SqlSugar
{
var name = disItem.Split(':').First();
var value = disItem.Split(':').Last();
queryable.Where(name, "=", value);
queryable.Where(shortName+name, "=", value);
}
}
}