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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:44:01+00:00 2026-05-14T14:44:01+00:00

I am looking for an automated way to iterate over all ObjectQueries and set

  • 0

I am looking for an automated way to iterate over all ObjectQueries and set the merge option to no tracking (read only context). Once i find out how to do it i will be able to generate a default read only context using a T4 template. Is this possible?

For example lets say i have these tables in my object context

SampleContext

  • TableA
  • TableB
  • TableC

I would have to go through and do the below.

SampleContext sc = new SampleContext();
sc.TableA.MergeOption = MergeOption.NoTracking;
sc.TableB.MergeOption = MergeOption.NoTracking;
sc.TableC.MergeOption = MergeOption.NoTracking;

I am trying to find a way to generalize this using object context.

I want to get it down to something like

foreach(var objectQuery : sc){
    objectQuery.MergeOption = MergeOption.NoTracking;
}

Preferably I would like to do it using the baseclass(ObjectContext):

ObjectContext baseClass = sc as ObjectContext
var objectQueries = sc.MetadataWorkspace.GetItem("Magic Object Query Option);

But i am not sure i can even get access to the queries. Any help would be appreciated.

  • 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-14T14:44:01+00:00Added an answer on May 14, 2026 at 2:44 pm

    I think reflection will be the only choice for this. Something along the lines of:

    IEnumerable<ObjectQuery> queries = from pd in context.GetType().GetProperties()
       where pd.PropertyType.IsSubclassOf(typeof(ObjectQuery))
       select (ObjectQuery)pd.GetValue(context, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im looking for a way of running a Twitter Search (Automated via CRON) that
I am looking for a simple and automated way to store the page cache
I've been looking for an easy and automated way to detect changes on my
I'm looking for easy way to count all rows within one SQL Server 2005/2008
I am looking for a way to automate the production of an offline product
I'm looking for an automatic way in eclipse to reformat curly braces to K&R
I'm looking into sending regular automated text-messages to a list of subscribed users. Having
I'm currently looking for ways to create automated tests for a JAX-RS (Java API
I'm looking to develop a scalable IM bot (aka Automated Service Agent). It's been
I'm looking for examples where a human-based service replaced an automated one. For example,

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.