title: How to Iterate a list whose index has two values and both the values have to be inserted in sql table
body: <p>I parsed an XML response and saved it in a List. The list looks like </p>
  
  <pre><code>[0] = { EmpId = "1999", EmpName = "Wilkins, Alan" }
  [1] = { EmpId = "1573", EmpName = "Sean, Jay" }
  [2] = { EmpId = "780", EmpName = "James, Parry" }
  </code></pre>
  
  <p>and so on...</p>
  
  <p>How do I iterate this list and insert the values in a sql table database</p>
  
  <p>I wrote the below code. Query is the variable where I'm parsing the XML data.</p>
  
  <pre><code>var data = query.ToList();
  
  foreach (var item in data)
  {
      _context.Employee.Add(employee);
      await _context.SaveChangesAsync();
  }
  </code></pre>
  
  <p>What am I doing wrong? The data isn't getting inserted in database.</p>
  
  <p>I have a Sql table where the list data is to be saved like below--</p>
  
  <pre><code>dbo.[Employee]
  
  EmpID EmpName
  1999  Wilkins, Alan
  1573  Sean, Jay
  780   James, Parry
  </code></pre>