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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:46:50+00:00 2026-05-26T01:46:50+00:00

i would like to insert records in set of batches. For example, lets say

  • 0

i would like to insert records in set of batches. For example, lets say I have 10,000 records to be inserted. I want to insert them in batches of 500 or 1,000. How can I do this dynamically? That is…take the first 500 or 1,000 insert them, take the next and insert them, and so forth. In my example, the set of 10,000 is made up of a Generic List, so I want to insert, or divide up, this List accordingly.

The count of 10,000 will not be a static count. May be less or more. Just want to insert in batches of 500 or 1,000.

  • 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-26T01:46:50+00:00Added an answer on May 26, 2026 at 1:46 am

    Using Linq-to-Sql to perform the INSERT‘s will not be efficient because it will always run them as individual INSERT statements even if you send in batches. You can try using a library or 3rd party code like this one for sending the batches: http://devio.wordpress.com/2011/08/05/batch-insert-using-linq-to-sql/.

    As far as splitting up your lists, you can do something like this:

    var first = myList.Take(500);
    var second = myList.Skip(500).Take(500);
    var third = myList.Skip(1000).Take(500);
    // etc.
    

    Obviously this could be done in a loop by incrementing the Skip amount instead of creating a separate variable for each section – I’m just showing the idea.

    Also you may find these links helpful:

    • Why massive inserts using SubmitChanges lack in performance.
    • Batch Updates and Deletes with LINQ to SQL (I know this isn’t about INSERTing, but it gives some good background info on why Linq-to-Sql is inefficient at batching)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a trigger to perform following operation for inserted records:
I have an IEnumerable and I would like to do a batch insert (240,000+
I have a little problem where I would like to insert a svn diff
I have a JPA project and I would like to insert some initial data
I have created a test table in MySQL and would like to insert 10
I would like to delete records which are considered duplicates based on them having
Say that I have a table with a bunch of records, which I want
I would like to insert the current Subversion revision number (as reported by svnversion
I would like to insert dates in an emacs buffer like I do in
I would like to insert notes on the fixes to be done in specific

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.