Luis Aguilar
Luis Aguilar

Reputation: 4371

Linq - Merging property accessor expressions

I have a MemberExpression that contains the following: mail => mail.SomeProperty.

I want to generate a new member expression to access one level deeper in the hierarchy and have some result like the following: mail => mail.SomeProperty.OtherProperty.

How to do this?

Upvotes: 4

Views: 313

Answers (1)

Dan Bryant
Dan Bryant

Reputation: 27495

I believe you can use Expression.Property to construct a new MemberExpression that wraps the existing expression with an additional property reference. It takes an Expression for the first argument, which should be the original MemberExpression.

Upvotes: 4

Related Questions