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 6617081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:39:43+00:00 2026-05-25T20:39:43+00:00

I have code first implementation for flowing hierarchy, BaseContact{ Public int Id{get;set;} public string

  • 0

I have code first implementation for flowing hierarchy,

 BaseContact{
   Public int Id{get;set;}
   public string Name{get;set;} 
//..
 }

 Person:BaseContact{

   public string Designation{get;set;} 
//..
 }
Company:BaseContact{
     public int NumOfEmployees{get;set;} 
//..
 }

I want to identify person or company with by using only the Id value? Currently I am using reflection to identify whether it is a person or company. Is there any other way to identify it without doing too much?

  • 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-05-25T20:39:44+00:00Added an answer on May 25, 2026 at 8:39 pm

    In your BaseContact (assume it is an abstract class) add abstract property which will be implemented by other two classes.Use Enum to identify the property type as follows.

     public enum MyType
        {
         Person, 
         Company,
        };
    
        public abstract class BaseContact{
           public abstract MyType ContactType{get;}   
         }
    
        public class Person:BaseContact
       {
    
        public override MyType ContactType
        {
          get
          {
            return MyType.Person;
          }      
        }
       }
    
    public class Company:BaseContact
    {
        public override MyType ContactType
        {
          get
           {
             return MyType.Company;
           }  
        } 
     }
    

    Use your BaseContact repository to retrieve entities and use enum for type separation.

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

Sidebar

Related Questions

I have the following code: Public Shared Function GetAvailableManufacturers() As List(Of Manufacturer) 'first get
I have an AXIS2/JAX-WS web service using a code first implementation (yes I know,
I have the following code implementation of Breadth-First search. trait State{ def successors:Seq[State] def
Racking my brains on this one. I have the code below: the first stages
I have this code: tableList = [[NSMutableArray alloc] initWithObjects:@First View,@Second View,nil]; I have synthesized
Hi I have the code below, once the first (only) item in the menu
I have a .py file with lots of classes: class First(Second): #code class Third(Fourth):
I have been using this code with great success to pull out the first
I have the following C# code below. Object first = 5; Object second =
I have a fairly simple code, a button click event, with the first line

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.