Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8679733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:03:06+00:00 2026-06-12T21:03:06+00:00

Background: I have a custom class, which represents a Data Base Table, each property

  • 0

Background:
I have a custom class, which represents a Data Base Table, each property corresponding to a table column. The properties can be classified in three ways.

Example: Take for example a Person object.

  • MetaProperties: (Columns that are needed by the program)
    • Person_ID: used in table for indexing etc…
    • UserDefinedType: (UDT), complex class handling write-permission on the table.
    • Timestamp: needed to handle the UDT in C# DataTables
  • RealProperties: (actual traits that describe the real Person)
    • FullName
    • DateOfBirth
    • PlaceOfBirth
    • EyeColor
    • etc… (many more)
  • RawDataProperties: (these columns hold raw data from external sources)

    • Phys_EyeColor: the eye-color, as directly imported from the physical traits database, may be in unknown format, may have conflicting value with entry from other db, or any other data quality issue…
    • HR_FullName: full name as given in HR file
    • Web_FullName: full name as taken from a web form
    • Web_EyeColor: eye color as taken from web form
    • etc…

    public class Person
    {

    #region MetaProperties
    
    public int Person_ID { get; set; }
    public UserDefinedType UDT { get; set; }
    public DateTime timestamp { get; set; }
    
    #endregion
    
    
    #region RealProperties
    
    public string FullName { get; set; }
    public DateTime DateOfBirth { get; set; }
    public string PlaceOfBirth { get; set; }
    public Color EyeColor { get; set; }
    //...
    
    #endregion
    
    
    #region RawDataProperties
    
    public string Phys_EyeColor { get; set; }
    public string Phys_BodyHeight { get; set; }
    
    public string Web_FullName { get; set; }
    public string Web_EyeColor { get; set; }
    
    public string HR_FullName { get; set; }
    //...
    #endregion
    

    }

Question: How can I programmatically differentiate between these three types of properties in my Person class? The goal is to be able to iterate through properties of a certain type using System.Reflection or some other organisational construct. Pseudocode:

foreach(Property prop in Person.GetPropertiesOfType("RealProperty"){
... doSmth(prop);
}

I’m thinking about writing custom Attributes, and hanging them on to the properties, sort of like taggin.
But since I know nothing about custom Attributes, I would like to ask if I’m going down the proper path, or if there are any other better ways of doing this.

Note: the shown example may may not be the best in terms of program design, and I am well aware that inheritance or splitting up the class otherwise could solve this problem. But that is not my question – I want to know if properties in a class can be tagged or somehow differentiated between using custom categories.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:03:07+00:00Added an answer on June 12, 2026 at 9:03 pm

    You can do this with custom attributes.

        [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
        public class PropertyAttribute : System.Attribute
        {
           public PropertyType Type { get; private set; }
           public PropertyAttribute (PropertyType type) { Type = type; }
        }
    
        public enum PropertyType
        {
           Meta,
           Real,
           Raw,
        }
    

    Then, you can do this with each property or field:

    [PropertyType(PropertyType.Meta)]
    public int Person_ID;
    [PropertyType(PropertyType.Real)]
    public string FullName;
    [PropertyType(PropertyType.Raw)]
    public string Phys_EyeColor;
    

    Then you can access it with something like

    foreach (PropertyAttribute attr in this.GetType().GetCustomAttributes(typeof(PropertyAttribute), false))
    {
        // Do something based on attr.Type
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: I have a MainTest class that has many buttons, each of which instantiate
I have a background MovieClip in a custom button class, which moves the play
I have a .NET PropertyGrid control which displays properties of some class. I want
I have a custom adapter which formats for me, alphabet headers and then corresponding
I have a custom DownloadFiles class which extends AsyncTask . The app launches itself
I have a custom class in Obj-C called RouteManager which contains an array of
I have a custom ListView adapter which implements an ImageThreadLoader class. Unfortunately, the class
I have a custom ListView adapter which implements an ImageThreadLoader class. Unfortunately the class
I have a ListBox which is bound to my custom class ObservableCollection<FieldPropertyItem> _fieldOrderCollection`; internal
I have a custom control of class DottedCanvas inherited from Canvas, which contains some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.