Update SugarColumn.QuerySql

This commit is contained in:
sunkaixuan 2023-12-18 13:46:00 +08:00
parent 8bddf50c59
commit 056a95068d

View File

@ -438,7 +438,7 @@ namespace SqlSugar
if (sqlObj.SelectString == null)
{
var columns = navEntityInfo.Columns.Where(it => !it.IsIgnore)
.Select(it => QueryBuilder.Builder.GetTranslationColumnName(it.DbColumnName) + " AS " + QueryBuilder.Builder.GetTranslationColumnName(it.PropertyName)).ToList();
.Select(it => GetOneToOneSelectByColumnInfo(it)).ToList();
sqlObj.SelectString = String.Join(",", columns);
}
var navList = selector(childDb.Queryable<object>(sqlObj.TableShortName).AS(GetDbTableName(navEntityInfo)).ClearFilter(QueryBuilder.RemoveFilters).Filter(this.QueryBuilder?.IsDisabledGobalFilter == true ? null : navEntityInfo.Type).AddParameters(sqlObj.Parameters).Where(conditionalModels).WhereIF(sqlObj.WhereString.HasValue(), sqlObj.WhereString).WhereIF(navObjectNameColumnInfo?.Navigat?.WhereSql!=null, navObjectNameColumnInfo?.Navigat?.WhereSql).Select(sqlObj.SelectString).OrderByIF(sqlObj.OrderByString.HasValue(), sqlObj.OrderByString));
@ -922,5 +922,14 @@ namespace SqlSugar
});
}
}
private string GetOneToOneSelectByColumnInfo(EntityColumnInfo it)
{
if (it.QuerySql.HasValue())
{
return it.QuerySql + " AS " + QueryBuilder.Builder.GetTranslationColumnName(it.PropertyName);
}
return QueryBuilder.Builder.GetTranslationColumnName(it.DbColumnName) + " AS " + QueryBuilder.Builder.GetTranslationColumnName(it.PropertyName);
}
}
}