Type type = t.GetType();
PropertyInfo pro = type.GetProperty(name);
ParameterExpression param_obj = Expression.Parameter(type, "obj");
var body_obj = Expression.Convert(param_obj, type);
var param_body = Expression.Property(param_obj, pro);
var body = Expression.Convert(param_body, typeof(object));
Func<T, object> func = Expression.Lambda<Func<T, object>>(body, param_obj).Compile();
return func(t);
Expression
最新推荐文章于 2022-01-31 14:07:56 发布