public static PropertyInfo GetPropertyInfo <T>( this Expression <Func <T, object> > expression) { MemberExpression memberExpression = GeneralExtensions.RemoveUnary(expression.Body); if (memberExpression == null) { return((PropertyInfo)null); } if (memberExpression.Member is PropertyInfo) { return(memberExpression.Member as PropertyInfo); } throw new ArgumentException("Cannot pass null to GetPropertyInfo"); }
public static MemberInfo GetMember(this LambdaExpression expression) { return(GeneralExtensions.RemoveUnary(expression.Body)?.Member); }