0

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.

Kev
  • 2,656
  • 3
  • 39
  • 63
  • are you sure IProduct inherits from IAuditable ? can you show us it's definition ? – Selman Genç May 30 '14 at 16:36
  • Possibly [ASP.net MVC v2 - Debugging Model Binding Issues - BUG?](http://stackoverflow.com/questions/1676731/asp-net-mvc-v2-debugging-model-binding-issues-bug) and [Inherited Interface property not found by Model Binding](http://stackoverflow.com/questions/7968304/inherited-interface-property-not-found-by-model-binding) – Jonathan Lonowski May 30 '14 at 16:47
  • @Selman22 I have added the IProduct interface above. – Kev Jun 02 '14 at 08:49
  • 1
    This could happen if your concrete class implements IAuditable but implements CreatedOn explicitly. Can you show an example of a concrete class that implements IProduct – Philip Pittle Jun 02 '14 at 10:34

0 Answers0