Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Root interface property not accessible via parent interface in Html helper

I feel like I am missing something basic here.

I have 2 interfaces. One is called IIdentifiable which specifies the existence of an Id property. The second can really be anything that is also identifiable. See code below.

public interface IIdentifiable
{
    Guid Id { get; set; }
}
public interface IPerson : IIdentifiable
{
    string Name { get; set; }
}

The problem:

When using the Html.HiddenFor (or any other helper method) and the model is strongly typed to the IPerson interface, I get an error when accessing the properties of the IIdentifiable interface. I can access and display the data in the IIdentifiable properties by going directly against Model.Id but not when using the lambda expression and accessing the model that way.

The error I get is "The property *.IPerson.Id could not be found".

This only seems to be the case when using the Razor view engine. I know this was working using ASP.NET MVC 2 and the WebForms view engine. I haven't tried it on the ASP.NET MVC 3 using the WebForms view engine yet.

like image 840
Adam Carr Avatar asked Nov 05 '22 04:11

Adam Carr


1 Answers

Yes, I have brought this to the attention of Microsoft by opening a ticket. Also see this related question.

like image 60
Darin Dimitrov Avatar answered Nov 09 '22 16:11

Darin Dimitrov