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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:23:04+00:00 2026-06-10T04:23:04+00:00

I am trying to eager load properties of a derived class in an Entity

  • 0

I am trying to eager load properties of a derived class in an Entity Framework model.

I read all over the place that I have to first filter the set with OfType() before including properties with Include():

var persons = Context.Persons
                     .OfType<Employee>()
                     .Include("Compensation")

I don’t know how to get that Include() to work though because in my case, Persons is a DbSet, OfType() returns an IQueryable and IQueryable does not define an Include() method.

  • 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-10T04:23:05+00:00Added an answer on June 10, 2026 at 4:23 am

    Place this:

    using System.Data.Entity;
    

    into your using’s list, and after that you will be able to use Include extension methods family from DbExtensions class:

        public static IQueryable<T> Include<T, TProperty>(this IQueryable<T> source, Expression<Func<T, TProperty>> path) where T : class;
        public static IQueryable<T> Include<T>(this IQueryable<T> source, string path) where T : class;
        public static IQueryable Include(this IQueryable source, string path);
    

    They accept IQueryable as the first argument, and there are strongly-typed ones, too, which is better, then Include(String).

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

Sidebar

Related Questions

I have an object model that looks like this (pseudo code): class Product {
i'm trying to eager load some child entity, and when I try to add
I have a problem trying the following with nHibernate: Eager loading. Use selects (here
in my user table i have two users when trying to select all users
suppose i have @Entity A, which has an eager @ManyToOne to @Entity B, and
I have an instance of a class that I got from a Hibernate session.
I'm trying to create a UserControl that inherits from a generic class. It does
What I am trying is to load all the A entities in the database
I'm trying to set the fetchmode to eager for a property that is two
I'm trying to eager load roles in many to many collection off of my

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.