Entity Group Transactions
In case we have several entities to insert into the table, we have the option to perform a batch operation that can insert many records in one group transaction. We can use the TableBatchOperation
and add the entities to it, then perform the CloudTable.ExecuteBatch
.
The following is some sample code to add two weathers at the same time:
TableBatchOperation batchOperation = new TableBatchOperation(); WeatherEntity weather1 = new WeatherEntity("5809844", "201503151300") { CityName = "Seattle", CountryCode = "US", Description = "Light Rain", Temperature = "23", Humidity = "82", Wind = "16 km/h", }; WeatherEntity weather2 = new WeatherEntity("5809844", "201503151400") { CityName = "Seattle", CountryCode = "US", Description = "Heavy Rain", Temperature = "20", Humidity = "95", Wind = "16 km/h", }; batchOperation.Insert(weather1); batchOperation.Insert(weather2); table.ExecuteBatch(batchOperation...