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

  • SEARCH
  • Home
  • 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 8311929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:58:44+00:00 2026-06-08T19:58:44+00:00

I am simplyfing the question here, so the example could not make any sence

  • 0

I am simplyfing the question here, so the example could not make any sence for the real world.

public class BusinessEntity<T>
{
    public int Id {get; set;}
}

public class Customer : BusinessEntity<Customer>
{

    public string FirstName { get; set;}
    public string LastName { get; set;}
}

When I try to get Customer class properties by reflection, I could not get the properties of the generic base class. How to get Id from the BusinessEntity ?

Type type = typeof(Customer);

PropertyInfo[] properties = type.GetProperties(); 
// Just FirstName and LastName listed here. I also need Id here 
  • 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-08T19:58:45+00:00Added an answer on June 8, 2026 at 7:58 pm

    Nope, that definitely returns all 3 properties. Check that in your real code, whether Id is internal / protected / etc (i.e. non-public). If it is, you’ll need to pass in BindingFlags, for example:

    PropertyInfo[] properties = type.GetProperties(
        BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
    

    (the default is public + instance + static)

    Also check that it isn’t a field in your actual code; if it is:

    public int Id;
    

    then it is a field, and you should use GetFields make Id a property ;p

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a design/algorithm question. Here's the outline of my scenario: I have a
Bit of a long explanation below, with a hopefully accurate short question summary here:
The same question has been asked for MySQL here , anyway that syntax doesn't
I'm simplifying my example to get to the heart of my question. I have
This maybe a stupid question, but as I can not easily undo my change
I´ll try to be short as the question has not been very answered. For
In this question, I had help in simplifying and forming a valid complicated JSON
I have a form with 3 fields (simplyfied example). The first one is a
I have three types of questions: Vocab (represented by question:answer pairs) Grammar (represented by
simple question mainly for simplifying purposes but... currently using var categoryList = []; $('#share').children().each(function()

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.