Data Annotations In Base Class

2 posts, 0 answers
  1. Scott
    Scott avatar
    38 posts
    Member since:
    Sep 2012

    Posted 10 Mar 2015 Link to this post

    I'm trying to use the DataFilter to filter data on my ScheduleView.  I have a custom class called StaffResource that inherits from Resource, in which I have several properties such as Staff Name, Office, etc.  I only want some of these properties to show up in the Member Dropdown of the DataFilter, so I mark them with Data Annotations.  My issue is that I can't get into the base Resource class to mark those 3 properties so they don't show up in the DataFilter.  Right now the datafilter shows DisplayName, ResourceName, and ResourceType in the dropdown, which I don't want.  How would I get those to not show up?
  2. Scott
    Scott avatar
    38 posts
    Member since:
    Sep 2012

    Posted 10 Mar 2015 in reply to Scott Link to this post

    I figured out the answer.  I just created properties in my child class that had the same name as the parent Resource class and used the 'new' keyword, then decorated those with the data annotations.

    [Display(AutoGenerateFilter = false)]
            public new string DisplayName
            {
                get
                {
                    return base.DisplayName;
                }
                set
                {
                    base.DisplayName = value;
                }
            }
  3. DevCraft banner
Back to Top