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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:06:53+00:00 2026-06-06T12:06:53+00:00

What could be the best preferable way of returning back a modified list grabbed

  • 0

What could be the best preferable way of returning back a modified list grabbed from an Entity Framework to our database.

Question In a simpler form :

How to return a Custom List e.g List of about 100,000 records to the database
these are the modified version of our entities in an offline Thread-safe manner.

The Code :

        var query = From context.Products
                    select p;

        var listQuery = query.ToList();

Edit : Seems that all the attached Lists to Entities will cause Thread-Safety errors.
So we have to make a cloned version of the list, something like List
and after edition insert all the items in a regular time-consuming or a shorthand way,
Any Ideas ?

Sample Steps :

  1. Make and fill an Custom List Array of our defined type from an entity DataContext
  2. Iterate through the List ( about 100,000 items)
  3. Edit the List
  4. Finally Return it back to the database

How to pass listQuery to the database ?

Iterating through each of them and find the equivalent entity or record via Entity/Linq and change the item ?? could it be the best idea or do we have any shorthand or best practice doing this ?
Any suggestion or idea ?

  • 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-06-06T12:06:54+00:00Added an answer on June 6, 2026 at 12:06 pm

    First, there is a slight error in your code example. You need to add ‘from p in context.Products’ rather than ‘from context.Products’

    If I am understanding correctly, the way i typically edit a list of records is:

                var products = dbContext.Products.ToList(); // Gets As List
                foreach (var product in products)
                {
                    // edit the value, EF manages what is changed
                    product.someField = "some new value";
                }
                dbContext.SaveChanges(); // Saves All Changes
    

    I prefer to use method syntax. If you prefer to use query syntax, you can replace the first line with:

    var products = (from p in products
                    select p).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could anyone guide me as to the best way to upload a collection of
I was wondering if someone could tell me the best way to call a
What would be the best way I could convert english text to sql queries.
I searched through here as best I could and though I found some relevant
I was hoping you folks could recommend a best practice for source controlling binary
I'd like to know what could be the best approach to develop a Windows
The title is a bit wonky but it's the best I could come up
Could someone please advise the current best practice around Date and Calendar types. When
Here are the best implementations I could find for lazy infinite sequences of Fibonacci
I am very new to Ruby so could you please suggest the best practice

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.