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

Can anybody help me to build an XSD file to validate XMLs like these:
Can these two SVN clients collaborate? I have my projects checked out with Tortoise,
I have a program which has some Textareas / Labels these can be anywhere
I have a JSON array with ActiveRecord objects. These objects can be reconstructed using
I want to provide dynamic download of files. These files can be generated on-the-fly
Can I get a 'when to use' for these and others? <% %> <%#
Can anyone provide a clear explanation / example of what these functions do, and
Can someone put in perspective the difference between JPA and Hibernate. Or are these
What are the most common problems that can be solved with both these data
apparently it works Can you name reasons beyond good practices not to give these

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.