Possible Duplicate:
Getting the values of method parameters inside expression trees
Given the following code:
@for (int i = 0; i < Model.FormerAddresses.Count; i++)
{
<li>@Html.Editable(m => m.FormerAddresses[i].Street)</li>
}
How do I get the value of ‘i’ in my ‘Editable’ extension? I know I can get the value of this expression by doing the following:
var value = ((LambdaExpression)expression).Compile().DynamicInvoke(MyViewModel);
But how do I get the value of the ‘i’? It should be possible since compiling the expression returns me the correct result, but I cannot find a way to find out how this is done. Any help will be appreciated.
Found it! Thanks StackOverflow. Was using the wrong search terms I guess.
Link to answer:
Getting the values of method parameters inside expression trees