Synchronization code

This commit is contained in:
sunkaixuan 2023-08-14 16:59:21 +08:00
parent b91f91e6b3
commit ab2b011d06
2 changed files with 25 additions and 0 deletions

View File

@ -40,6 +40,27 @@ namespace SqlSugar
parameter.Context.Result.Append(this.Context.GetAsString2(asName, GetNewExpressionValue(childExpression)));
return;
}
else if (ExpressionTool.GetMethodName(item) == "ToString"
&& (item as MethodCallExpression)?.Arguments?.Count() == 0
&& (item as MethodCallExpression)?.Object?.Type?.IsEnum==true
&& this.Context?.SugarContext?.QueryBuilder != null)
{
var childExpression = (item as MethodCallExpression)?.Object;
var type = childExpression.Type;
if (this.Context.SugarContext.QueryBuilder.QueryableFormats == null)
{
this.Context.SugarContext.QueryBuilder.QueryableFormats = new List<QueryableFormat>();
}
this.Context.SugarContext.QueryBuilder.QueryableFormats.Add(new QueryableFormat()
{
PropertyName = asName,
Type = type,
TypeString = "Enum",
MethodName = "ToString"
});
parameter.Context.Result.Append(this.Context.GetAsString2(asName, GetNewExpressionValue(childExpression)));
return;
}
this.Expression = item;
this.Start();
if (ExpressionTool.GetMethodName(item) == "MappingColumn")

View File

@ -60,6 +60,10 @@ namespace SqlSugar
{
addValue = Convert.ToDouble(addValue + "").ToString(valueFomatInfo.Format);
}
else if (valueFomatInfo.TypeString == "Enum")
{
addValue =ChangeType2( addValue,valueFomatInfo.Type)?.ToString();
}
}
return addValue;
}