- 修复 ToSql AsProperty 大小别名问题;

This commit is contained in:
2881099
2022-08-17 15:15:17 +08:00
parent 3a58084afc
commit c43a90787c
3 changed files with 23 additions and 11 deletions

View File

@ -51,6 +51,16 @@ namespace FreeSql.Internal
public bool ReadAnonymousField(List<SelectTableInfo> _tables, Func<Type, string, string> _tableRule, StringBuilder field, ReadAnonymousTypeInfo parent, ref int index, Expression exp, Select0Provider select,
BaseDiyMemberExpression diymemexp, List<GlobalFilter.Item> whereGlobalFilter, List<string> findIncludeMany, List<Expression> findSubSelectMany, bool isAllDtoMap)
{
bool LocalEndsWithField(string dbField, string dbNestedField)
{
switch (_ado.DataType)
{
case DataType.SqlServer:
case DataType.OdbcSqlServer:
return dbField.EndsWith(dbNestedField, StringComparison.CurrentCultureIgnoreCase);
}
return dbField.EndsWith(dbNestedField);
}
void LocalSetFieldAlias(ref int localIndex, bool isdiymemexp)
{
if (localIndex >= 0)
@ -63,7 +73,7 @@ namespace FreeSql.Internal
else if (string.IsNullOrEmpty(parent.CsName) == false)
{
parent.DbNestedField = GetFieldAsCsName(parent.CsName);
if (localIndex == ReadAnonymousFieldAsCsName && parent.DbField.EndsWith(parent.DbNestedField, StringComparison.CurrentCultureIgnoreCase) == false) //DbField 和 CsName 相同的时候,不处理
if (localIndex == ReadAnonymousFieldAsCsName && LocalEndsWithField(parent.DbField, parent.DbNestedField) == false) //DbField 和 CsName 相同的时候,不处理
field.Append(_common.FieldAsAlias(parent.DbNestedField));
}
}
@ -253,7 +263,7 @@ namespace FreeSql.Internal
else if (string.IsNullOrEmpty(parent.CsName) == false)
{
dbNestedField = GetFieldAsCsName(parent.CsName);
if (index == ReadAnonymousFieldAsCsName && diymemexp._field.EndsWith(dbNestedField, StringComparison.CurrentCultureIgnoreCase) == false) //DbField 和 CsName 相同的时候,不处理
if (index == ReadAnonymousFieldAsCsName && LocalEndsWithField(diymemexp._field, dbNestedField) == false) //DbField 和 CsName 相同的时候,不处理
field.Append(_common.FieldAsAlias(dbNestedField));
}
}