Example #1
0
        public static ICqlBatch WithOptions(this ICqlBatch batch, CassandraQueryOptions queryOptions)
        {
            return(batch.WithOptions(o =>
            {
                if (queryOptions == null)
                {
                    return;
                }

                if (queryOptions.ConsistencyLevel.HasValue)
                {
                    o.SetConsistencyLevel(queryOptions.ConsistencyLevel.Value);
                }

                if (queryOptions.PageSize.HasValue)
                {
                    o.SetPageSize(queryOptions.PageSize.Value);
                }

                if (queryOptions.TracingEnabled.HasValue)
                {
                    if (queryOptions.TracingEnabled.Value)
                    {
                        o.EnableTracing();
                    }
                    else
                    {
                        o.DisableTracing();
                    }
                }
            }));
        }
Example #2
0
        public static Task <IdentityResult> TryExecuteBatchAsync(this IMapper mapper,
                                                                 CassandraErrorDescriber errorDescriber,
                                                                 ILogger logger,
                                                                 CassandraQueryOptions options,
                                                                 params Action <ICqlBatch>[] actions)
        {
            var batch = mapper
                        .CreateBatch()
                        .WithOptions(options);

            foreach (var a in actions)
            {
                a(batch);
            }

            return(TryExecuteAsync(() => mapper.ExecuteAsync(batch), errorDescriber, logger));
        }
Example #3
0
        public static void ExecuteWithOptions(
            this ICqlBatch batch,
            string cql,
            CassandraQueryOptions queryOptions,
            params object[] args)
        {
            batch.WithOptions(o =>
            {
                if (queryOptions == null)
                {
                    return;
                }

                if (queryOptions.ConsistencyLevel.HasValue)
                {
                    o.SetConsistencyLevel(queryOptions.ConsistencyLevel.Value);
                }

                if (queryOptions.PageSize.HasValue)
                {
                    o.SetPageSize(queryOptions.PageSize.Value);
                }

                if (queryOptions.TracingEnabled.HasValue)
                {
                    if (queryOptions.TracingEnabled.Value)
                    {
                        o.EnableTracing();
                    }
                    else
                    {
                        o.DisableTracing();
                    }
                }
            })
            .Execute(cql, args);
        }