I am developing an ASP.NET MVC4 application, first with EF code. I have a base class:
public class Entity { public int Id { get; set; } public string Title { get; set; } }
And I have some derived classes, for example:
public class City : Entity { public int Population { get; set; } }
And many other derived classes (article, topic, car, etc.). Now I want to implement the “Required” attribute for the Title property in all classes and I want different ErrorMessages to exist for different derived classes. For example, “Name must not be empty” for the class “Class”, “Name your car” for the class of cars, etc. How can i do this? Thanks!
c # asp.net-mvc
ifeelgood
source share