- 优化 ExpressionTree 类型转换的友好错误提示;

This commit is contained in:
2881099 2019-07-20 15:19:21 +08:00
parent 9cc8da637d
commit 2550611410

View File

@ -1770,8 +1770,15 @@ namespace FreeSql.Internal
var exp = GetDataReaderValueBlockExpression(type, parmExp);
return Expression.Lambda<Func<object, object>>(exp, parmExp).Compile();
});
try
{
return func(value);
}
catch (Exception ex)
{
throw new ArgumentException($"ExpressionTree 转换类型错误,值({string.Concat(value)}),类型({value.GetType().FullName}),目标类型({type.FullName}){ex.Message}");
}
}
public static string GetCsName(string name)
{
name = Regex.Replace(name.TrimStart('@'), @"[^\w]", "_");