want to insert a list of objects into sql server table. I just wonder if there is a way I can insert all the objects in the record list at one time?
public int stockInsert()
{
int result = 0;
string queryStr = "insert into Stock(stockID,color_Available,size_Available,qty_Available,detail_Img,productId)"
+ "values(@stockID,@color_Available,@size_Available,@qty_Available,@detail_Img,@productId)";
con.Open();
SqlCommand cmd = new SqlCommand(queryStr, con);
cmd.Parameters.AddWithValue("@stockID", this.StockID);
cmd.Parameters.AddWithValue("@color_Available", this.ColorAvailable);
cmd.Parameters.AddWithValue("@size_Available", this.SizeAvailable);
cmd.Parameters.AddWithValue("@qty_Available", this.QtyAvailable);
cmd.Parameters.AddWithValue("@detail_Img", this.DetailImg);
cmd.Parameters.AddWithValue("@productId", this.ProductID);
result += cmd.ExecuteNonQuery();
con.Close();
return result;
}