Monday, 15 June 2015

c# - What is the Maximum Number of Records i can insert through InserAllOnSubmit() In Linq to Sql -


I am reading the Excel sheet and applying my business argument and I LINQ to SQL .

In my loop I have & gt; (More than 5000 records) and & lt; Insert (less than) 15,000 records . Public List & lt; TblLog & gt; TblLogList = New list & lt; TblLog & gt; ();

This method is inside looping:

  Public Zero SaveLog () {tblLog tnlog = new tblLog (); Tnlog.id = Guide. Newguide (); Tnlog.comp_id = Comp_id; Tnlog.branch_id = Branch_id; Tnlog.row_id = rowID; Tnlog.his_id = his_id; // Add a record to the list of tblLogList.Add (tnlog);   

Before I tried to submit this code one by one:

  //_trContext.tblLogs.InsertOnSubmit (TblLog); // _ trContext.SubmitChanges ();   

Due to the performance hit, I changed the InsertOnSubmit to InsertAllOnSubmit

  if (tblLogList Count & gt; = 1000) {_trContext.tblLogs.InsertAllOnSubmit (tblLogList); _trContext.SubmitChanges (); TblLogList.Clear (); }}    

Here's my question:

  1. Maximum number of records I can insert through InserAllOnSubmit (In SQL in the link.

  2. Through the code given above I have achieved 1000 records, but I swear when code goes for 10,000 or more records This is some timeout exception because it has been applied to my ** windows service ** .

    I'm really confused, What were the best suggestions for handling the above logic?

    Thanks in advance.

    While others have a right to say that there is a better solution for this task, there is a direct answer to your question so far.

    The answer is That the technically number is limited to the amount of memory, the context swallows all these new items, or the maximum size database transactions Oggs are more likely to be interrupted, but you can stop them from reaching both the boundaries by recording hundreds of thousands or thousands of amounts for each batch and using a new reference (!) You can.

    As you said, there can be a practical limit command time-out (if you do not want to make it infinite) it can also be affected by cuts in batches , And thus, starting a new order for each batch.

    The functional range depends on things such as the process is inaccessible or not the patience), and whether the data is expected to be available within a certain time. If these requirements are tight, then you may have to resort to one of the solutions given in other answers.

No comments:

Post a Comment