- 修复 Enum.ToString() 即使 MapType=int 也应解析成 string;#1252 #806

This commit is contained in:
2881099
2023-06-28 17:44:13 +08:00
parent b164a08747
commit 2a3db8a2c2
28 changed files with 325 additions and 56 deletions

View File

@ -86,7 +86,18 @@ namespace FreeSql.Sqlite
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
return null;
case "ToString":
if (callExp.Object != null) return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as character)" : null;
if (callExp.Object != null)
{
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
{
tsc.SetMapColumnTmp(null);
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
return enumStr;
}
return callExp.Arguments.Count == 0 ? $"cast({getExp(callExp.Object)} as character)" : null;
}
return null;
}