I have an interface IProduct : IAuditable
public interface IProduct : IAuditable
{
string Code { get; set; }
string Name { get; set; }
string Description { get; set; }
ProductItemsList Items { get; }
ProductType Type { get; }
}
Where IAuditable is defined as:
public interface IAuditable
{
DateTimeOffset CreatedOn { get; }
int CreatedBy { get; }
DateTimeOffset ModifiedOn { get; }
int ModifiedBy { get; }
}
In a view that is bound to an enumerable of IProduct,
This works: (btw ReSharper tells me to remove the cast)
@Html.DisplayFor(model => ((IAuditable)model.ModelObject).CreatedOn)
But this fails:
@Html.DisplayFor(model => model.ModelObject.CreatedOn)
(with error "MyProj.Products.IProduct.CreatedOn could not be found")
Can someone explain this to me. It's Friday afternoon so I'm probably being stupid.