Generic method to get property values with Linq Expression and reflection

后端 未结 2 1320
南旧
南旧 2021-01-27 00:23

Dear Gods of Reflection

I would like to have a generic GetValue method that can return the following property values given the following

2条回答
  •  遇见更好的自我
    2021-01-27 00:45

    You can do it simply by Executing your Lambda expression:

            if (response != null)
            {
                return propertyExpression.Compile().Invoke(response);
            }
    

提交回复
热议问题