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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:25:05+00:00 2026-05-14T20:25:05+00:00

How can I do these 2 scenarios. Currently I am doing something like this

  • 0

How can I do these 2 scenarios.

Currently I am doing something like this

public class Repository
{
     private LinqtoSqlContext dbcontext = new LinqtoSqlContext();

   public void Update()
   {
   // find record
   // update record
   // save record ( dbcontext.submitChanges()
   }

   public void Insert()
   {
      // make a database table object ( ie ProductTable t = new ProductTable() { productname 
           ="something"}
      // insert record ( dbcontext.ProductTable.insertOnSubmit())
     // dbcontext.submitChanges();
   }
}

So now I am trying to load an XML file what has tons of records. First I validate the records one at a time. I then want to insert them into the database but instead of doing submitChanges() after each record I want to do a mass submit at the end.

So I have something like this

public class Repository
{
    private LinqtoSqlContext dbcontext = new LinqtoSqlContext();
   public void Update()
   {
   // find record
   // update record
   }

   public void Insert()
   {
      // make a database table object ( ie ProductTable t = new ProductTable() { productname 
           ="something"}
      // insert record ( dbcontext.ProductTable.insertOnSubmit())
   }

   public void SaveToDb()
   {
      dbcontext.submitChanges();
   }
}

Then in my service layer I would do like

for(int i = 0; i < 100; i++)
{
    validate();
    if(valid == true)
    {
       update();
       insert()
    }
}

SaveToDb();

So pretend my for loop is has a count for all the record found in the xml file. I first validate it. If valid then I have to update a table before I insert the record. I then insert the record.

After that I want to save everything in one go.

I am not sure if I can do a mass save when updating of if that has to be after every time or what.

But I thought it would work for sure for the insert one.

Nothing seems to crash and I am not sure how to check if the records are being added to the dbcontext.

  • 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-14T20:25:06+00:00Added an answer on May 14, 2026 at 8:25 pm

    The simple answer is: you do not. Linq2Sql is a lot of things – it is not a replacement for bulk upload / bulk copy. You will be a LOT more efficient using the ETL route:

    • Generate a flat file (csv etc.) with the new data
    • Load it into the database using bulk load mechanisms
    • If the data is updating etc. – load it into temporary tables and use the MERGE command to merge it into the main table.

    Linq2Sql will by design always suck in mass insert scenarios. ORM’s just are not ETL tools.

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

Sidebar

Related Questions

How can I implement these scenarios using forms authentication? If the user is Inactive
What is the usage of Execution Plan in SQL Server? When can these plans
We have Win Forms application uses the 3rd party windows native controls. Can these
I'm hoping someone here can answer these definitively: Does putting a VHD file in
Is there an image processing algorithm that can fill these gaps within an image?
I'm looking for a Vim plugin that can do these kind of thing. Let's
Here's the output. These are utf-8 strings I believe... some of these can be
I have two tables (using table variables for illustration. You can run these directly
Requirements : I have a table of several thousand questions. Users can view these
Entity Framework has created the required partial classes. I can add these partial classes

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.