title: Bulk Insert of Generic List C# into SQL Server
body: <p>How can I bulk insert a generic list in c# into SQL Server, rather than looping through the list and inserting individual items one at a time?</p>
  
  <p>I currently have this;</p>
  
  <pre><code>private void AddSnapshotData()
  {
    var password =       Cryptography.DecryptString("vhx7Hv7hYD2bF9N4XhN5pkQm8MRfxi+kogALYqwqSuo=");
    var figDb = "ZEUS";
    var connString =
      String.Format(
        "Data Source=1xx.x.xx.xxx;Initial Catalog={0};;User ID=appuser;Password={1};MultipleActiveResultSets=True",
        figDb, password);
    var myConnection = new SqlConnection(connString);
    myConnection.Open();
  
    foreach (var holding in _dHoldList)
    {
      lbStatus.Text = "Adding information to SQL for client: " + holding.ClientNo;
      _reports.AddZeusData("tblAllBrooksHoldingsSnapshot", "CliNo, SEDOL, ISIN, QtyHeld, DateOfSnapshot",
                           "'" + holding.ClientNo + "','" + holding.Sedol + "','" + holding.ISIN + "','" +
                           holding.QuantityHeld + "','" + DateTime.Today.ToString("yyyyMMdd") + "'", false, myConnection);
    }
    myConnection.Close();
    lbStatus.Visible = false;
  }
  </code></pre>
  
  <p>Where <code>dHoldList</code> is a list of <code>DHOLDS</code>;</p>
  
  <pre><code>public class DHOLDS : ExcelReport
   {
  public String ClientNo { get; set; }
  public String Sedol { get; set; }
  public Double QuantityHeld { get; set; }
  public Double ValueOfStock { get; set; }
  public String Depot { get; set; }
  public String ValC4 { get; set; }
  public String StockR1 { get; set; }
  public String StockR2 { get; set; }
  public Double BookCost { get; set; }
  public String ISIN { get; set; }
  }
  </code></pre>