1

I have a ModelBase abstract class that I want all of my models to inherit:

public abstract class ModelBase : IModelBase
{
    // this base should be inherited by all model classes
    [ScaffoldColumn(false)]
    public DateTime? LastModifiedDate { get; set; }
    [ScaffoldColumn(false)]
    public DateTime? CreatedDate { get; set; }      
}

When I inherit that base class, the attributes for [ScaffoldColumn(false)] do not appear to be inherited:

public class Role : ModelBase
{
    [Key]
    public int Id { get; set; }
    public string Description { get; set; }
}

What this means is that the LastModifiedDate and CreatedDate get scaffolded (i.e., they will appear in the Create and Edit views) when I use the new VS 2013 scaffold template during Add Controller that builds my CRUD views.

If it's true that the Scaffold attribute isn't inherited because its AttributeUsageAttribute.Inherited property is set to false, then is there any way to to use inheritance or some other programming strategy to give all of my models the LastModifiedDate and CreatedDate properties while also letting the ScaffoldColumn tag along?

tereško
  • 58,060
  • 25
  • 98
  • 150
Jazimov
  • 12,626
  • 9
  • 52
  • 59

0 Answers0