mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 10:08:19 +08:00
Code optimization
This commit is contained in:
@@ -105,9 +105,9 @@ namespace SqlSugar
|
||||
{
|
||||
Check.ArgumentNullException(entityName, string.Format(ErrorMessage.ObjNotExist, "Table Name"));
|
||||
if (IsTranslationText(entityName)) return entityName;
|
||||
if (isMapping && this.MappingTables.IsValuable())
|
||||
{
|
||||
if (entityName.Contains("."))
|
||||
isMapping = isMapping && this.MappingTables.IsValuable();
|
||||
var isComplex = entityName.Contains(".");
|
||||
if (isMapping && isComplex)
|
||||
{
|
||||
var columnInfo = entityName.Split('.');
|
||||
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(columnInfo.Last(), StringComparison.CurrentCultureIgnoreCase));
|
||||
@@ -117,15 +117,12 @@ namespace SqlSugar
|
||||
}
|
||||
return string.Join(".", columnInfo.Select(it => GetTranslationText(it)));
|
||||
}
|
||||
else
|
||||
else if (isMapping)
|
||||
{
|
||||
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase));
|
||||
return SqlTranslationLeft+ (mappingInfo == null ? entityName : mappingInfo.EntityName) + SqlTranslationRight;
|
||||
return SqlTranslationLeft + (mappingInfo == null ? entityName : mappingInfo.EntityName) + SqlTranslationRight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entityName.Contains("."))
|
||||
else if (isComplex)
|
||||
{
|
||||
return string.Join(".", entityName.Split('.').Select(it => GetTranslationText(it)));
|
||||
}
|
||||
@@ -134,7 +131,6 @@ namespace SqlSugar
|
||||
return GetTranslationText(entityName);
|
||||
}
|
||||
}
|
||||
}
|
||||
public virtual string GetTranslationColumnName(string columnName)
|
||||
{
|
||||
Check.ArgumentNullException(columnName, string.Format(ErrorMessage.ObjNotExist, "column Name"));
|
||||
@@ -181,7 +177,7 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual string GetAsString(string asName, string fieldValue)
|
||||
{
|
||||
if (fieldValue.Contains(".*")|| fieldValue=="*") return fieldValue;
|
||||
if (fieldValue.Contains(".*") || fieldValue == "*") return fieldValue;
|
||||
return string.Format(" {0} {1} {2} ", GetTranslationColumnName(fieldValue), "AS", GetTranslationColumnName(asName));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user