title: InsertAll & UpdateAll in sqlite-net-pcl VS InsertOrReplaceAll in SQLite.Net-PCL
body: <p>I want to remove <a href="https://www.nuget.org/packages/SQLite.Net-PCL/" rel="nofollow noreferrer">SQLite.Net-PCL</a> package and want to use <a href="https://www.nuget.org/packages/sqlite-net-pcl/" rel="nofollow noreferrer">sqlite-net-pcl</a> because I later found that <code>SQLite.Net-PCL</code> is not officially being maintained.</p>
  <p>I have tables which stores <code>GUID</code> as primary key of string type in my Xamarin project. I have List of records coming from server and currently using <code>InsertOrReplaceAll</code> method to insert new records and update existing one, all at once based on my <code>GUID</code> primary key.</p>
  <p>Now, <code>sqlite-net-pcl</code> does not have <code>InsertOrReplaceAll</code> method but instead it has only <code>InsertAll</code> &amp; <code>UpdateAll</code> methods. <a href="https://msdn.microsoft.com/en-us/magazine/mt736454.aspx" rel="nofollow noreferrer">Microsoft msdn Link</a> says checking if primary key has value available or not and based on that decide if Records have to be inserted or updated.</p>
  <p>But, I have a case where primary key value is always pre-set in the <code>List</code>, before insert or update the object and don't want to make a loop to check if record exists or not for more than 500 records.</p>
  <p>How to Insert Or Replace all my records at once in this case?</p>
  <p>Consider following Example to understand this scenario:</p>
  <pre><code>using (var conn = new DBConnectionService().GetConnection())
  {       
      List&lt;ENTEmployee&gt; employees = new List&lt;ENTEmployee&gt;()
      {
          new ENTEmployee(){ Id = &quot;b977ec04-3bd7-4691-b4eb-ef47ed6796fd&quot;, FullName = &quot;AAA BBB&quot;, Salary = 15000 },
          new ENTEmployee(){ Id = &quot;c670a3e2-b13f-42b3-849c-fd792ebfd103&quot;, FullName = &quot;BBB BBB&quot;, Salary = 16000 },
          new ENTEmployee(){ Id = &quot;d961c33c-0244-48dc-8e10-f4f012386eb6&quot;, FullName = &quot;CCC BBB&quot;, Salary = 17000 },
          new ENTEmployee(){ Id = &quot;35be4508-ff93-4be8-983f-d4908bcc592d&quot;, FullName = &quot;DDD BBB&quot;, Salary = 18000 },
          new ENTEmployee(){ Id = &quot;0875549c-d06c-4983-b89a-edf81b6aa70d&quot;, FullName = &quot;EEE BBB&quot;, Salary = 19000 },
      };
  
      var insertResult = conn.InsertAll(employees);
  
      //Updated Record
      employees[0].FullName = &quot;AAA Updated&quot;;
      employees[0].Salary = 12300;
  
  
      //New Records
      employees.Add(new ENTEmployee() { Id = &quot;87f48ecf-715c-4327-9ef3-11712ba4a120&quot;, FullName = &quot;FFF BBB&quot;, Salary = 20000 });
      employees.Add(new ENTEmployee() { Id = &quot;85f53888-b1e9-460c-8d79-88010f143bcf&quot;, FullName = &quot;GGG BBB&quot;, Salary = 21000 });
  
      //Now here, 
      //How to decide which records to be inserted and which records to be updated for List employees?
  }
  </code></pre>