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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:10:13+00:00 2026-05-27T00:10:13+00:00

We are having a problem navigating between entities one of which is based on

  • 0

We are having a problem navigating between entities one of which is based on a view.
The problem is when we go

TableEntity.ViewEntity.Where(x => x.Id == Id).FirstOrDefault())

In the background it is loading all records in the view which is not what we want or expect.

However when we go

_objectContext.TableEntityView
    .Where(x => x.TableObjectId == TableObjectId && x.Id == Id)

Then it just loads up the one row which is what we are expecting

In short using the navigation properties causes a massive data load – it’s like the query is being realised early.

We are using EF 4 with SQL 2005 database. The views are used to provide aggregated information which EF couldn’t easily do without big data loads (ironically). We have manually constructed 1: Many associations between the views.

Why then do we get the large data load in the first instance but not the second?

Many thanks for all/any help

  • 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-27T00:10:14+00:00Added an answer on May 27, 2026 at 12:10 am

    That’s how navigation collections work in EF: accessing the collection loads all entities, and any linq queries you run thereafter simply query against the objects in memory. I don’t think there’s anything you can do about it short of a custom query like you’ve already done.

    FWIW I’m told NHibernate supports more fine-grained navigation loads, but that feature has yet to make its way into Entity Framework.

    EDIT

    This answer from Ladislav Mrnka shows a possible solution to your problem from the CTP days. Not sure if anything has changed since then. It uses the DbContext, so you still won’t be able to just plow through the navigation property, but it’s probably as close as you’re going to get.

    int count = context.Entry(myAccount)
                       .Collection(a =>  a.Orders).Query().Count();`
    

    or for your case, I’m guessing it would be

    TableEntityView obj = context.Entry(TableEntity)
                                 .Collection(a => a.ViewEntity)
                                 .Query().FirstOrDefault(x => x.Id == Id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem displaying an image in an image view, which is generated
We are having problem with the server migration. We have one application that are
I'm having problems mapping a relationaship between two entities when there are two columns
I'm having a problem with my navigation controller. If I add a view controller
i am having problem in navigating from UIWebview to back on my application screen
am having problem, my app doesn't seem to check the radio button based from
I am having a problem with creating a navigation controller after on the other
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
We're having problem with a huge number of legacy stored procedures at work. Do
I'm having problem in the following line: rd.PrintOptions.PaperSize = PaperSize.PaperFanfoldStdGerman; it throws an exception

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.