Beispiel #1
0
 private Cql(string cql, object[] args, CqlQueryOptions queryOptions)
 {
     AutoPage     = true;
     Statement    = cql;
     Arguments    = args;
     QueryOptions = queryOptions;
 }
        /// <inheritdoc />
        public Task DeleteAsync <T>(T poco, CqlQueryOptions queryOptions = null)
        {
            // Get the statement and bind values from POCO
            string             cql           = _cqlGenerator.GenerateDelete <T>();
            Func <T, object[]> getBindValues = _mapperFactory.GetValueCollector <T>(cql, primaryKeyValuesOnly: true);

            object[] values = getBindValues(poco);

            return(ExecuteAsync(Cql.New(cql, values, queryOptions ?? CqlQueryOptions.None)));
        }
        public void Update <T>(T poco, CqlQueryOptions queryOptions = null)
        {
            // Get statement and bind values from POCO
            string             cql           = _cqlGenerator.GenerateUpdate <T>();
            Func <T, object[]> getBindValues = _mapperFactory.GetValueCollector <T>(cql, primaryKeyValuesLast: true);

            object[] values = getBindValues(poco);

            _statements.Add(Cql.New(cql, values, queryOptions ?? CqlQueryOptions.None));
        }
        private void Insert <T>(bool ifNotExists, bool insertNulls, T poco, CqlQueryOptions queryOptions = null, int?ttl = 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);

            //generate INSERT query based on null values (if insertNulls set)
            object[] queryParameters;
            var      cql = _cqlGenerator.GenerateInsert <T>(insertNulls, values, out queryParameters, ifNotExists, ttl);

            _statements.Add(Cql.New(cql, queryParameters, queryOptions ?? CqlQueryOptions.None));
        }
        /// <inheritdoc />
        public Task InsertAsync <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, ttl: ttl);

            return(ExecuteAsync(Cql.New(cql, queryParameters, queryOptions ?? CqlQueryOptions.None)));
        }
 public CqlBatch(MapperFactory mapperFactory, CqlGenerator cqlGenerator, BatchType type)
 {
     if (mapperFactory == null)
     {
         throw new ArgumentNullException("mapperFactory");
     }
     if (cqlGenerator == null)
     {
         throw new ArgumentNullException("cqlGenerator");
     }
     _mapperFactory = mapperFactory;
     _cqlGenerator  = cqlGenerator;
     _statements    = new List <Cql>();
     BatchType      = type;
     Options        = new CqlQueryOptions();
 }
 /// <inheritdoc />
 public AppliedInfo <T> InsertIfNotExists <T>(T poco, CqlQueryOptions queryOptions = null)
 {
     return(InsertIfNotExists(poco, true, queryOptions));
 }
 /// <inheritdoc />
 public void Insert <T>(T poco, bool insertNulls, int?ttl, CqlQueryOptions queryOptions = null)
 {
     //Wait async method to be completed or throw
     TaskHelper.WaitToComplete(InsertAsync(poco, insertNulls, ttl, queryOptions), _queryAbortTimeout);
 }
 /// <inheritdoc />
 public void Insert <T>(T poco, bool insertNulls, CqlQueryOptions queryOptions = null)
 {
     Insert(poco, insertNulls, null, queryOptions);
 }
 /// <inheritdoc />
 public void Insert <T>(T poco, CqlQueryOptions queryOptions = null)
 {
     Insert(poco, true, queryOptions);
 }
 public void InsertIfNotExists <T>(T poco, bool insertNulls, int?ttl, CqlQueryOptions queryOptions = null)
 {
     Insert(true, insertNulls, poco, queryOptions, ttl);
 }
 public void Insert <T>(T poco, bool insertNulls, int?ttl, CqlQueryOptions queryOptions = null)
 {
     Insert(false, insertNulls, poco, queryOptions, ttl);
 }
 /// <inheritdoc />
 public void Delete <T>(T poco, CqlQueryOptions queryOptions = null)
 {
     //Wait async method to be completed or throw
     TaskHelper.WaitToComplete(DeleteAsync(poco, queryOptions), _queryAbortTimeout);
 }
 /// <inheritdoc />
 public Task <AppliedInfo <T> > InsertIfNotExistsAsync <T>(T poco, bool insertNulls, CqlQueryOptions queryOptions = null)
 {
     return(InsertIfNotExistsAsync(poco, insertNulls, null, queryOptions));
 }
 /// <inheritdoc />
 public Task <AppliedInfo <T> > InsertIfNotExistsAsync <T>(T poco, CqlQueryOptions queryOptions = null)
 {
     return(InsertIfNotExistsAsync(poco, true, queryOptions));
 }
 /// <inheritdoc />
 public Task InsertAsync <T>(T poco, bool insertNulls, CqlQueryOptions queryOptions = null)
 {
     return(InsertAsync(poco, insertNulls, null, queryOptions));
 }
 /// <inheritdoc />
 public Task InsertAsync <T>(T poco, CqlQueryOptions queryOptions = null)
 {
     return(InsertAsync(poco, true, queryOptions));
 }
 /// <inheritdoc />
 public Task <IPage <T> > FetchPageAsync <T>(CqlQueryOptions options = null)
 {
     return(FetchPageAsync <T>(Cql.New(string.Empty, new object[0], options ?? new CqlQueryOptions())));
 }
 /// <inheritdoc />
 public AppliedInfo <T> InsertIfNotExists <T>(T poco, bool insertNulls, CqlQueryOptions queryOptions = null)
 {
     return(InsertIfNotExists(poco, insertNulls, null, queryOptions));
 }
 /// <inheritdoc />
 public AppliedInfo <T> InsertIfNotExists <T>(T poco, bool insertNulls, int?ttl, CqlQueryOptions queryOptions = null)
 {
     return(TaskHelper.WaitToComplete(InsertIfNotExistsAsync(poco, insertNulls, ttl, queryOptions), _queryAbortTimeout));
 }
 /// <inheritdoc />
 public IEnumerable <T> Fetch <T>(CqlQueryOptions queryOptions = null)
 {
     // Just let the SQL be auto-generated
     return(Fetch <T>(Cql.New(string.Empty, new object[0], queryOptions ?? CqlQueryOptions.None)));
 }
 /// <inheritdoc />
 public Task <IEnumerable <T> > FetchAsync <T>(CqlQueryOptions options = null)
 {
     return(FetchAsync <T>(Cql.New(string.Empty, new object[0], options ?? CqlQueryOptions.None)));
 }
 /// <inheritdoc />
 public IPage <T> FetchPage <T>(CqlQueryOptions queryOptions = null)
 {
     return(FetchPage <T>(Cql.New(string.Empty, new object[0], queryOptions ?? new CqlQueryOptions())));
 }
Beispiel #24
0
 internal static Cql New(string cql, object[] args, CqlQueryOptions queryOptions)
 {
     return(new Cql(cql, args, queryOptions));
 }
 public void InsertIfNotExists <T>(T poco, CqlQueryOptions queryOptions = null)
 {
     InsertIfNotExists(poco, true, queryOptions);
 }