title: Linq2Sql InsertAllOnSubmit Vs Multiple InsertOnSubmit For Large Amounts Of Rows
body: <p>If I have say for example 100,000 rows to insert/update/delete, and this number will grow constantly. Which of the following is the best approach, or does it not make any difference.</p>
  
  <p>The PeopleRepository AddPeople implementation</p>
  
  <pre><code>public void AddPeople(IEnumerable i)
  {
      _Database.people.InsertAllOnSubmit(i);
  }
  </code></pre>
  
  <p>The PeopleRepository AddPerson implementation</p>
  
  <pre><code>public void AddPerson(Person p)
  {
      _Database.people.InsertOnSubmit(p);
  }
  </code></pre>
  
  <p>The PeopleRepository Save implementation</p>
  
  <pre><code>public void Save()
  {
      _Database.SubmitChanges();
  }
  </code></pre>
  
  <p>InsertAllOnSubmit Implementation</p>
  
  <pre><code>PeopleRepository repo = new PeopleRepository();
  
  List&lt;Person&gt; everyone = new List&lt;Person&gt;();
  
  foreach (var p in myObject.GetPeople())
  {
      Person person = new Person
      {
          person.Name = p.Name
      };
  
      everyone.Add(person);
  }
  
  repo.AddPeople(everyone);
  repo.Save();
  </code></pre>
  
  <p>InsertOnSubmit Implementation</p>
  
  <pre><code>PeopleRepository repo = new PeopleRepository();
  
  foreach (var p in myObject.GetPeople())
  {
      Person person = new Person
      {
          person.Name = p.Name
      };
  
      repo.AddPerson(person);
      repo.Save();
  }
  </code></pre>