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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:17:26+00:00 2026-05-15T20:17:26+00:00

I am trying to use inherited types with EF, which has been all cool

  • 0

I am trying to use inherited types with EF, which has been all cool and gravy until now.

I have a base type (Person) and two types that inherit person (Employee & Customer). I run into a problem when I want a person to be an Employee and a Customer at the same time. For example:

Person person = db.Persons.Single(p => p.id == id);

if (person is Employee)
{
    Console.WriteLine("Person is an employee");
}

//True only if person is Employee == false
if (person is Customer)
{
    Console.WriteLine("Person is a customer");
}

If I map a Person to an Employee and a Customer, “Person is Customer” always returns false until I remove the Employee mapping from the person.

And I am not sure what that is called… but there is a table per type (Person is a table, Customer is a table, and Employee is a table in the DB).

  • 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-15T20:17:26+00:00Added an answer on May 15, 2026 at 8:17 pm

    You can’t do this since you can not have multiple inheritance.

    Within your DB Customer and Employee tables I would suggest foriegn key into the Person table. Then in your object model the Customer and Employee there would be a Person property.

    As you are just wanting to iterate over whether they are Customers or Employee’s just use linq on those collections which should be on the Entity context

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

Sidebar

Related Questions

I'm trying to force an inherited class to use a custom attribute. I'm creating
Hi I'm trying use a datepicker on a field I have. I'm trying to
Trying to use an excpetion class which could provide location reference for XML parsing,
Trying to use this method (gist of which is use self.method_name in the FunnyHelper
I've inherited a bunch of Fluent NHibernate mappings, which all currently work in the
I am trying to use Generic Types in Windows.Resources section in XAML code. To
I have inherited some verbose, repetitious code that I am trying to refactor. The
I have been trying to develop some user controls, one being a text edit
I am trying to use the time interval algebra methods on event types directly,
I have a JSP where I'm trying to use JSTL tags to display data

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.