code optimization

This commit is contained in:
skx 2020-11-15 12:56:24 +08:00
parent b1be604dc2
commit ccfd52d223

View File

@ -442,22 +442,7 @@ namespace SqlSugar
}
else
{
var propertyName = property.Name;
var dbColumnName = propertyName;
var mappingInfo = this.Context.MappingColumns.FirstOrDefault(it => it.EntityName == item.Type.Name && it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
if (mappingInfo.HasValue())
{
dbColumnName = mappingInfo.DbColumnName;
}
asName = this.Context.GetTranslationText(item.Type.Name + "." + propertyName);
if (Context.IsJoin)
{
this.Context.Result.Append(Context.GetAsString(asName, dbColumnName, shortName.ObjToString()));
}
else
{
this.Context.Result.Append(Context.GetAsString(asName, dbColumnName));
}
asName = GetAsName(item, shortName, property);
}
}
}
@ -496,6 +481,29 @@ namespace SqlSugar
}
}
private string GetAsName(Expression item, object shortName, PropertyInfo property)
{
string asName;
var propertyName = property.Name;
var dbColumnName = propertyName;
var mappingInfo = this.Context.MappingColumns.FirstOrDefault(it => it.EntityName == item.Type.Name && it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
if (mappingInfo.HasValue())
{
dbColumnName = mappingInfo.DbColumnName;
}
asName = this.Context.GetTranslationText(item.Type.Name + "." + propertyName);
if (Context.IsJoin)
{
this.Context.Result.Append(Context.GetAsString(asName, dbColumnName, shortName.ObjToString()));
}
else
{
this.Context.Result.Append(Context.GetAsString(asName, dbColumnName));
}
return asName;
}
private static bool IsBoolValue(Expression item)
{
return item.Type == UtilConstants.BoolType &&