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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:09:53+00:00 2026-05-17T00:09:53+00:00

First let me start by explaining my use case: Say there is a database

  • 0

First let me start by explaining my use case:

Say there is a database “Cars”. In that database, each row might have Make, Model, EngineType, etc. I have a page that is essentially a view of a single “Car” record, displaying its various stats. In that page, I have a user control that calculates and displys various MPG stats based on the “Car” record. The user control is passed the “Car” record via a property, then uses it internally for its calculations.

Inside that user control, something like this happens:

private void DataBindGrid()
{
    gridView.DataSource = this.CarRecord.GetMPGStats();
}

Internal to “CarRecord”, is a LINQ-to-SQL query, using the data context of CarRecord. For the purpose of this calculation, it would be more efficient to do this:

private void DataBindGrid()
{
    DataLoadOptions dlo = new DataLoadOptions();

    dlo.LoadWith<Car>(c => c.Engine);

    this.CarRecord.DataContext.LoadOptions = dlo;

    gridView.DataSource = this.CarRecord.GetMPGStats();
}

For the purpose of this example, ignore whether or not this may be a bad design for a user control passing in a record & datacontext.

Here are the issues I’m seeing:

  • The page may have set its own load options before passing the record to the user control, resulting in an inefficient query.
  • The page may not want the new settings specified by the user control when it continues to use the Car record itself.

So I have two questions:

  1. What is the best way to “clear” LoadOptions? Simply set DataContext.LoadOptions = new DataLoadOptions(); or = null;?
  2. Is there any way to set some sort of temporary LoadOptions that only affect a certain operation before reverting to whatever they were before?

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-17T00:09:54+00:00Added an answer on May 17, 2026 at 12:09 am

    data load options always have to be set before execution of first query. once a query executes there is nothing u can do with them.

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

Sidebar

Related Questions

First let me say that I know it's better to use the subprocess module,
First let me start by saying that I don't have a complete understanding of
Before I start explaining the code I will first give my use case so
Let me first say that I have quite a lot of Java experience, but
First off, let me start by saying that I am totally new to working
First let me say I have read this useful article thoroughly and am using
First let me say that I did see this article: How to remove AspxAutoDetectCookieSupport
First let me explain. I have several addresses on the page that I put
Let me start by explaining this is my first Android app. So I don't
Ok, let me first start off by saying that I've only ever dealt with

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.