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

  • Home
  • SEARCH
  • 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 127477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:28:58+00:00 2026-05-11T05:28:58+00:00

I have an ASP.NET MVC (using the release candidate) application that works with a

  • 0

I have an ASP.NET MVC (using the release candidate) application that works with a class library that among other things uses LINQ to SQL for data persistance.

One of the thing the app/db maintains, is the concept of a ‘Folder’ – like a disk folder, but with a hierarchy that only exists in the database. Other database objects live in these folders, seen from the perspective of the user.

Each class in the class library has its own static reference to my DataContext object. In addition, the MVC controller each has it’s own DataContext object.

I have two Actions returning JSON data. One is a ‘GetFoldersJSON’ which returns the folder structure in a format suitable for a select (dropdown) list. The other one is ‘AddFolderJSON’ which accepts some form data, inserts a new Folder into the database, and then returns GetFoldersJSON() for sending the new folder list to the client. The client uses AJAX with these actions to refresh the dropdownlists once a new folder is created.

The flow of this operation is as such:

  1. AddFolderJSON() action – Get the form information with new folder name, parent folder etc.

  2. Create new Folder object. Perform a dataContext.Folders.InsertOnSubmit(newFolder); Perform a dataContext.SubmitChanges(); Perform a dataContext.Refresh(OverwriteThingy, dataContext.Folders); return result of GetFoldersJSON()

  3. GetFoldersJSON() uses a function which resides in the Folder definition – a partial class extending the OR-mapped folder object. This function recursively adds folders and subfolders to a flat list using code like this:

    var rootFolders = from f in db.Folders                   where f.ParentFolder == null                   orderby f.name                   select f; 

db is of course the local, static DataContext reference.

Then a simple loop:

    foreach (var fldr in rootFolders)     {         AddFolderContents(list, fldr);     } 

The AddFolderContents() function then adds the current folder to the list, and proceeds to call itself for each subfolder of the current folder, thus creating a hierarchy.

This works fine for data already in the database, but when we run this procedure after creating a new Folder, the new folder does not show up. If we refresh the page, it still doesn’t show up. It doesn’t actually show up until the application is restarted.

I have tried to do Refresh() calls just about everywhere, and it seems to have no effect in this case.

Is there a way to tell LINQ to SQL ‘Hey, I know what you’re thinking, but DROP IT ALL, and just get ALL the data from the database, NOW!’?

I have a nagging feeling I’ve heard about this before, but couldn’t find it described here.

  • 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. 2026-05-11T05:28:59+00:00Added an answer on May 11, 2026 at 5:28 am

    Is there a way to tell LINQ to SQL ‘Hey, I know what you’re thinking, but DROP IT ALL, and just get ALL the data from the database, NOW!’?

    db = new customDataContext();

    db is of course the local, static DataContext reference

    Yeah, watch out there. ASP.NET is multithreaded and you don’t want to share an unsafe-for-threading DataContext instance.


    It seems as though you are accessing children folders through their parents. DataContext caches the state of objects it has already read and returns those same instances to you on further querying. The parent instance needs to be notified that it has a new child instance. Check out the generated ParentFolder property and see if it notifies the parent folder. If so, you’re in business:

    child.ParentFolder = parent; 

    If not, you need to do it this way:

    parent.Children.Add(child); 

    Do not do it by id, the autogenerated code does not notify the parent object in this case.

    child.ParentFolderId = parent.Id; //bad, broken, do not do 

    Do this before your SubmitChanges call.

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

Sidebar

Ask A Question

Stats

  • Questions 93k
  • Answers 93k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Turns out the MSDN documentation and Visual Studio 2008 disagree… May 11, 2026 at 6:43 pm
  • Editorial Team
    Editorial Team added an answer I would recommend an in-memory database for running your unit… May 11, 2026 at 6:43 pm
  • Editorial Team
    Editorial Team added an answer I'm going to buck the trend here a bit. I… May 11, 2026 at 6:43 pm

Related Questions

In RC1 the behavior of the template for creating a view changed. As explained
Having just upgraded to the latest ASP.NET MVC Release Candidate I noticed that, when
I'm currently in the process of updating a site from preview 2 of ASP.NET
I am starting to learn ASP.NET MVC. I have deployed the stock ASP.NET MVC

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.