c.For(x => Html.TextBoxFor(y => x.Name)) such an expression is incorrectly parsed.
In debug the expression for TextBoxFor is
{y => value(System.Runtime.CompilerServices.StrongBox`1[ListModelBinding.Models.ItemModel]).Value.Name}
As you can see there is a ".Value" that is not stripped away like ".Model".
In my opinion the code should be:
// If it starts with "model", then strip that away
if (nameParts.Count > 0 && (String.Equals(nameParts.Peek(), ".model", StringComparison.OrdinalIgnoreCase) ||
String.Equals(nameParts.Peek(), ".value", StringComparison.OrdinalIgnoreCase)))
{
nameParts.Pop();
}
See also on stackoverflow: http://stackoverflow.com/questions/13543073/asp-net-mvc-expressionhelper-getexpressiontext-returning-wrong-property-name
In debug the expression for TextBoxFor is
{y => value(System.Runtime.CompilerServices.StrongBox`1[ListModelBinding.Models.ItemModel]).Value.Name}
As you can see there is a ".Value" that is not stripped away like ".Model".
In my opinion the code should be:
// If it starts with "model", then strip that away
if (nameParts.Count > 0 && (String.Equals(nameParts.Peek(), ".model", StringComparison.OrdinalIgnoreCase) ||
String.Equals(nameParts.Peek(), ".value", StringComparison.OrdinalIgnoreCase)))
{
nameParts.Pop();
}
See also on stackoverflow: http://stackoverflow.com/questions/13543073/asp-net-mvc-expressionhelper-getexpressiontext-returning-wrong-property-name