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

The Archive Base Latest Questions

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

The workflow of my app is quite simple: For a given bunch of scripts

  • 0

The workflow of my app is quite simple:

For a given bunch of scripts

  1. take a script
  2. parse it
  3. get corresponding object graph from db
  4. update it or create new if no graph found
  5. save changes
  6. detach graph from object context for GC could kill the graph

The last item of the list is not necessary if object context is created for each script but it affects performance, moreover I want some of the entities stored in the context whereas others collected by GC.

I thought of manually detaching entities:

foreach (var desc in component.Descriptions)
   context.ComponentDescription.Detach(desc);
context.Components.Detach(component);

Such enumeration implies db querying in case of enabled lazy loading. It’s not a good thing at all.

I found such a way more like a hack:

var entities = context.ObjectStateManager.GetObjectStateEntries(EntityState.Unchanged).Where(
                        e => !(e.Entity is ComponentType));
entities.Iterate(e => e.ChangeState(EntityState.Detached));

Well, it’s not a graph detaching, but I just know I can do this in my case. But what if I need to work with the certain graph, how can I detach related properties without ‘disturbing’ db?

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

    As I your question the problem is call to component.Descriptions because it triggers lazy loading if descriptions are not loaded. So the solution should be easy. Temporary disable lazy loading during this operation.

    context.ContextOptions.LazyLoadingEnabled = false;
    
    foreach (var desc in component.Descriptions)
       context.ComponentDescription.Detach(desc);
    context.Components.Detach(component);
    
    context.ContextOptions.LazyLoadingEnabled = true;
    

    I don’t understand why do you thing that creating context for each operation affects performance. The reverse is usually true – reusing context affects performance.

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

Sidebar

Related Questions

I have the following workflow I am looking for a Rails app: Parse incoming
I'm building a workflow app to investigate the technology. I can't decide whether to
In my Workflow Foundation 4.0 RC app I have a 'Receive' and 'SendReplyToReceive' WCF
Say I just found a bug involving javascript workflow in a web app. Most
I have an XML workflow where we're building an output document from an XML
I have a Workflow 4.0 app that generates emails. In a dialog for creating
I am sketching out the workflow of an app where you have a main
I currently have this workflow in a tab based app: Tab1 loads... ViewOne :
I was working on a Java EE app that took in user requests from
We have a web app (ASP) that has workflow in it for management to

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.