public Task AddAsync(string groupId, SignalType signal, long version, List<AffinityGroupMostSignaledInsertOptions> options) { string rowKey = BuildRowKey(groupId, signal, version); var batch = new BatchStatement(); foreach (var option in options) { BoundStatement boundStatement = _insertStatement.Value.Bind(rowKey, option.Count, option.ItemId); batch.Add(boundStatement); } return _session.Get().ExecuteAsync(batch.SetConsistencyLevel(ConsistencyLevel.One)); }
public void AddTopic(Guid topicId, string title, string body) { //We will be inserting 2 rows in 2 column families. //One for the topic and other for the first message (the topic body). //We will do it in a batch, this way we can ensure that the 2 rows are inserted in the same atomic operation. var batch = new BatchStatement(); //bind the parameters on each statement and add them to the batch batch.Add(_insertTopicStatement.Bind(topicId, title, DateTime.Now)); batch.Add(_insertMessageStatement.Bind(topicId, DateTime.Now, body)); //You can set other options of the batch execution, for example the consistency level. batch.SetConsistencyLevel(ConsistencyLevel.Quorum); //Execute the insert of the 2 rows Session.Execute(batch); }