The Sheek Geek
The Sheek Geek

Reputation: 4216

Getting Class Property Values from Linq Expression In Html Helper MVC3

I have an HTML helper that I need to pass an Object to. This Object is a class that has some Properties on it that I would need to access in the helper. The actual base class of this object is a generic type so I decided that I would use a Linq expression and pass it the object.

Here is the method signature:

public static MvcHtmlString PartyDetailsField<TModel, TProperty>(this HtmlHelper<TModel> helper, string controlLabelText, Expression<Func<TModel, TProperty>> expression, IEnumerable<IDetailsConfiguration> configuation, string width = "")

Here is how I use the control:

@Html.PartyDetailsField("Identifiers", m => m.Person, Model.IdentifierConfiguration, "186px")

I need the instance information from m.Person. How can I get the object instance and access the properties of the class instance from the expression? Is there a better way of doing this?

Upvotes: 1

Views: 951

Answers (1)

Related Questions