private Cql(string cql, object[] args, CqlQueryOptions queryOptions) { AutoPage = true; Statement = cql; Arguments = args; QueryOptions = queryOptions; }
public CqlBatch(MapperFactory mapperFactory, CqlGenerator cqlGenerator, BatchType type) { _mapperFactory = mapperFactory ?? throw new ArgumentNullException(nameof(mapperFactory)); _cqlGenerator = cqlGenerator ?? throw new ArgumentNullException(nameof(cqlGenerator)); _statements = new List <Cql>(); BatchType = type; Options = new CqlQueryOptions(); }
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)); }
public Task InsertAsync <T>(T poco, CqlQueryOptions queryOptions = null) { // Get statement and bind values from POCO string cql = _cqlGenerator.GenerateInsert <T>(); Func <T, object[]> getBindValues = _mapperFactory.GetValueCollector <T>(cql); object[] values = getBindValues(poco); return(ExecuteAsync(Cql.New(cql, values, queryOptions ?? CqlQueryOptions.None))); }
private void Insert <T>(bool ifNotExists, T poco, CqlQueryOptions queryOptions = null) { // Get statement and bind values from POCO string cql = _cqlGenerator.GenerateInsert <T>(ifNotExists); Func <T, object[]> getBindValues = _mapperFactory.GetValueCollector <T>(cql); object[] values = getBindValues(poco); _statements.Add(Cql.New(cql, values, queryOptions ?? CqlQueryOptions.None)); }
/// <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 Task <AppliedInfo <T> > InsertIfNotExistsAsync <T>(T poco, CqlQueryOptions queryOptions = null) { // Get statement and bind values from POCO var cql = _cqlGenerator.GenerateInsert <T>(true); var getBindValues = _mapperFactory.GetValueCollector <T>(cql); var values = getBindValues(poco); return(ExecuteAsyncAndAdapt( Cql.New(cql, values, queryOptions ?? CqlQueryOptions.None), (stmt, rs) => AppliedInfo <T> .FromRowSet(_mapperFactory, cql, rs))); }
private void Insert <T>(bool ifNotExists, bool insertNulls, T poco, CqlQueryOptions queryOptions = null, int?ttl = null) { var pocoData = _mapperFactory.PocoDataFactory.GetPocoData <T>(); var queryIdentifier = $"INSERT ID {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) var cql = _cqlGenerator.GenerateInsert <T>(insertNulls, values, out var queryParameters, ifNotExists, ttl); var cqlInstance = Cql.New(cql, queryParameters, queryOptions ?? CqlQueryOptions.None); _statements.Add(cqlInstance); }
/// <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))); }
private void Insert <T>(bool ifNotExists, bool insertNulls, T poco, 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); //generate INSERT query based on null values (if insertNulls set) object[] queryParameters; var cql = _cqlGenerator.GenerateInsert <T>(insertNulls, values, out queryParameters, ifNotExists); _statements.Add(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 Task DeleteAsync <T>(T poco, string executionProfile, CqlQueryOptions queryOptions = null) { if (executionProfile == null) { throw new ArgumentNullException(nameof(executionProfile)); } // 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); var cqlInstance = Cql.New(cql, values, queryOptions ?? CqlQueryOptions.None).WithExecutionProfile(executionProfile); return(ExecuteAsync(cqlInstance)); }
/// <inheritdoc /> public AppliedInfo <T> InsertIfNotExists <T>(T poco, CqlQueryOptions queryOptions = null) { return(InsertIfNotExists(poco, true, queryOptions)); }
/// <inheritdoc /> public AppliedInfo <T> InsertIfNotExists <T>(T poco, bool insertNulls, CqlQueryOptions queryOptions = null) { return(InsertIfNotExists(poco, insertNulls, null, queryOptions)); }
/// <inheritdoc /> public void Insert <T>(T poco, bool insertNulls, int?ttl, CqlQueryOptions queryOptions = null) { Insert(poco, Configuration.DefaultExecutionProfileName, insertNulls, ttl, queryOptions); }
/// <inheritdoc /> public void Insert <T>(T poco, string executionProfile, bool insertNulls, int?ttl, CqlQueryOptions queryOptions = null) { if (executionProfile == null) { throw new ArgumentNullException(nameof(executionProfile)); } //Wait async method to be completed or throw TaskHelper.WaitToComplete(InsertAsync(poco, executionProfile, insertNulls, ttl, queryOptions), _queryAbortTimeout); }
/// <inheritdoc /> public Task <AppliedInfo <T> > InsertIfNotExistsAsync <T>(T poco, string executionProfile, bool insertNulls, int?ttl, CqlQueryOptions queryOptions = null) { if (executionProfile == null) { throw new ArgumentNullException(nameof(executionProfile)); } var pocoData = _mapperFactory.PocoDataFactory.GetPocoData <T>(); var queryIdentifier = $"INSERT ID {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) var cql = _cqlGenerator.GenerateInsert <T>(insertNulls, values, out var queryParameters, true, ttl); var cqlInstance = Cql.New(cql, queryParameters, queryOptions ?? CqlQueryOptions.None).WithExecutionProfile(executionProfile); return(ExecuteAsyncAndAdapt( cqlInstance, (stmt, rs) => AppliedInfo <T> .FromRowSet(_mapperFactory, cql, rs))); }
/// <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 void Insert <T>(T poco, string executionProfile, CqlQueryOptions queryOptions = null) { Insert(poco, executionProfile, true, queryOptions); }
/// <inheritdoc /> public void Update <T>(T poco, CqlQueryOptions queryOptions = null) { //Wait async method to be completed or throw TaskHelper.WaitToComplete(UpdateAsync(poco, queryOptions), _queryAbortTimeout); }
/// <inheritdoc /> public IPage <T> FetchPage <T>(CqlQueryOptions queryOptions = null) { return(FetchPage <T>(Cql.New(string.Empty, new object[0], queryOptions ?? new CqlQueryOptions()))); }
/// <inheritdoc /> public void Insert <T>(T poco, CqlQueryOptions queryOptions = null) { Insert(poco, true, queryOptions); }
/// <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))); }
internal static Cql New(string cql, object[] args, CqlQueryOptions queryOptions) { return new Cql(cql, args, queryOptions); }
/// <inheritdoc /> public Task DeleteAsync <T>(T poco, CqlQueryOptions queryOptions = null) { return(DeleteAsync(poco, Configuration.DefaultExecutionProfileName, queryOptions)); }
/// <inheritdoc /> public AppliedInfo <T> InsertIfNotExists <T>(T poco, string executionProfile, bool insertNulls, CqlQueryOptions queryOptions = null) { return(InsertIfNotExists(poco, executionProfile, insertNulls, null, queryOptions)); }
/// <inheritdoc /> public void Insert <T>(T poco, bool insertNulls, CqlQueryOptions queryOptions = null) { Insert(poco, insertNulls, null, queryOptions); }
/// <inheritdoc /> public AppliedInfo <T> InsertIfNotExists <T>(T poco, string executionProfile, bool insertNulls, int?ttl, CqlQueryOptions queryOptions = null) { return(TaskHelper.WaitToComplete(InsertIfNotExistsAsync(poco, executionProfile, insertNulls, ttl, queryOptions), _queryAbortTimeout)); }
/// <inheritdoc /> public void Insert <T>(T poco, string executionProfile, bool insertNulls, CqlQueryOptions queryOptions = null) { Insert(poco, executionProfile, insertNulls, null, queryOptions); }
/// <inheritdoc /> public void Delete <T>(T poco, string executionProfile, CqlQueryOptions queryOptions = null) { //Wait async method to be completed or throw TaskHelper.WaitToComplete(DeleteAsync(poco, executionProfile, queryOptions), _queryAbortTimeout); }
/// <inheritdoc /> public Task <AppliedInfo <T> > InsertIfNotExistsAsync <T>(T poco, bool insertNulls, int?ttl, CqlQueryOptions queryOptions = null) { return(InsertIfNotExistsAsync(poco, Configuration.DefaultExecutionProfileName, insertNulls, ttl, queryOptions)); }