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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:40:34+00:00 2026-05-25T14:40:34+00:00

So I have classes that looks like this. public class User { public virtual

  • 0

So I have classes that looks like this.

public class User {
    public virtual IList<Member> Members {get;set;}
}

public class Member {
    public virtual AnotherTable Another {get;set;}
}

public class AnotherTable {
    public string Name {get;set;}
}

When I perform the query directly against the DataContext the Include works, but when I do an AsQueryable() on the IList of members the include doesn’t work.

Is there a way to have Include/Eager functionality on lazy loaded properties, such as the Members property above, or do I always have to go through the DataContext to get that feature?

User.Members.AsQueryable().Include(a => a.Another).ToList() // <-- nada, no way Jose
_db.Members.Include(m => m.Another).ToList() // <-- all good in the neighborhood

I ask cause it can be a huge difference of 1 sql query vs. 100 queries for something result equivalent.

Thanks in advance.

  • 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-25T14:40:34+00:00Added an answer on May 25, 2026 at 2:40 pm

    AsQueryable doesn’t make it linq-to-entities query. It is still Linq-to-object query on top of List. List doesn’t know how to handle Include – only DbQuery knows it so you must get DbQuery:

    var entry = context.Entry(user);
    entry.Collection(u => u.Member).Query().Include(m => m.Another).Load();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have service classes that look something like this public class UserService :
I have a Java class that looks like this: public class My_ABC { int
I have a model that looks something like this: public class SampleModel { public
I have an hierarchy of classes that looks like the following: class Critical {
I have multiple classes that I need to map into 1 class: This is
I have a base class that I want to look like this: class B
I have, let's say, this simple class: public class User { [Required(AllowEmptyStrings = false,
Im on php 5.2.x I have a loader class that looks like so: class
I have a bool array that looks like this bool[] responses = new bool[]
I have some JSON data that looks like this: { data: [{ name:John Smith,

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.