/// <inheritdoc /> public async Task <AppliedInfo <T> > ExecuteConditionalAsync <T>(ICqlBatch batch) { if (batch == null) { throw new ArgumentNullException("batch"); } var batchStatement = await _statementFactory .GetBatchStatementAsync(_session, batch) .ConfigureAwait(false); //Use the concatenation of cql strings as hash for the mapper var cqlString = string.Join(";", batch.Statements.Select(s => s.Statement)); var rs = await _session.ExecuteAsync(batchStatement).ConfigureAwait(false); return(AppliedInfo <T> .FromRowSet(_mapperFactory, cqlString, rs)); }
/// <inheritdoc /> public Task <AppliedInfo <T> > InsertIfNotExistsAsync <T>(T poco, bool insertNulls, int?ttl, CqlQueryOptions queryOptions = null) { var pocoData = _mapperFactory.PocoDataFactory.GetPocoData <T>(); var queryIdentifier = string.Format("INSERT ID {0}/{1}", pocoData.KeyspaceName, pocoData.TableName); var getBindValues = _mapperFactory.GetValueCollector <T>(queryIdentifier); //get values first to identify null values var values = getBindValues(poco); object[] queryParameters; //generate INSERT query based on null values (if insertNulls set) var cql = _cqlGenerator.GenerateInsert <T>(insertNulls, values, out queryParameters, true, ttl); return(ExecuteAsyncAndAdapt( Cql.New(cql, queryParameters, queryOptions ?? CqlQueryOptions.None), (stmt, rs) => AppliedInfo <T> .FromRowSet(_mapperFactory, cql, rs))); }
/// <inheritdoc /> public Task <AppliedInfo <T> > DeleteIfAsync <T>(Cql cql) { _cqlGenerator.PrependDelete <T>(cql); return(ExecuteAsyncAndAdapt(cql, (stmt, rs) => AppliedInfo <T> .FromRowSet(_mapperFactory, cql.Statement, rs))); }