This is a migrated thread and some comments may be shown as answers.

Data Annotations In Base Class

1 Answer 56 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 10 Mar 2015, 05:58 PM
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?

1 Answer, 1 is accepted

Sort by
0
Scott
Top achievements
Rank 1
answered on 10 Mar 2015, 07:12 PM
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;
            }
        }
Tags
DataFilter
Asked by
Scott
Top achievements
Rank 1
Answers by
Scott
Top achievements
Rank 1
Share this question
or