public void BulkSaveData(List <TemperatureSensorDBModel> temps) { var output = new DataTable(); output.Columns.Add("Temperature", typeof(float)); output.Columns.Add("Humidity", typeof(float)); output.Columns.Add("TimeCaptured", typeof(DateTime)); foreach (var temp in temps) { output.Rows.Add(temp.Temperature, temp.Humidity, temp.TimeCaptured); } _sql.InsertDataSet("dbo.spTemperatureSensor_InsertSet", output, "WeatherStationDB", "TemperatureSensorUDT"); }
public async Task <int> Insert(List <PenjualanViewModel> datas) { var dataTable = new DataTable(); dataTable.Columns.Add("noPenerimaan"); dataTable.Columns.Add("kdBarang"); dataTable.Columns.Add("jmlBeli"); dataTable.Columns.Add("harga"); dataTable.Columns.Add("diskon"); dataTable.Columns.Add("idUser"); foreach (var item in datas) { dataTable.Rows.Add(item.NoPenerimaan, item.KdBarang, item.JmlBeli, item.Harga, item.Diskon, "11111"); } var p = new { data = dataTable.AsTableValuedParameter("penjualanUDT") }; return(await _db.InsertDataSet <PenjualanViewModel, dynamic>("dbo.sp_penjulan", dataTable, p)); }