Exemple #1
0
        public void Delete<M>(List<M> modelsToDelete, IDeleteModel deleteModel) where M : IModel, new()
        {
            var queries = modelsToDelete.Select(m => deleteModel.GetDeleteString(m)).ToList();
            var batches = CreateBatches(queries);

            batches.ForEach(b =>
            {
                var task = _cassandraSession.ExecuteAsync(b);
                task.Wait();
            });
        }
        public void Delete <M>(List <M> modelsToDelete, IDeleteModel deleteModel) where M : IModel, new()
        {
            List <string> deleteQueries = new List <string>();

            foreach (var model in modelsToDelete)
            {
                var deleteQueryText = deleteModel.GetDeleteString(model);
                deleteQueries.Add(deleteQueryText);
            }

            var filtersAndProjection = MultipleBsonToSingleFilterAndProjection(deleteQueries);

            _database.GetCollection <M>(nameof(M)).DeleteMany(filtersAndProjection.Filter);
        }
        public void Delete <M>(List <M> modelsToDelete, IDeleteModel deleteModel) where M : IModel, new()
        {
            string[] deleteQueries = new string[modelsToDelete.Count];
            for (int i = 0; i < modelsToDelete.Count; i++)
            {
                deleteQueries[i] = deleteModel.GetDeleteString(modelsToDelete[i]);
            }

            using (var trans = _connection.BeginTransaction())
            {
                _connection.Execute(UtilityFunctions.FlattenQueries(deleteQueries), commandTimeout: Int32.MaxValue);
                trans.Commit();
            }
        }
Exemple #4
0
        public void Delete <M>(List <M> modelsToDelete, IDeleteModel deleteModel) where M : IModel, new()
        {
            List <Task> deletionTasks = new List <Task>();

            foreach (var model in modelsToDelete)
            {
                var deleteStr  = deleteModel.GetDeleteString(model);
                var cmdAndArgs = this.SeparateCmdAndArguments(deleteStr);

                // Note that this ExecuteAsync command will only be executed once creationBatch.Execute() is called
                var deleteTask = _databaseConnection.ExecuteAsync(cmdAndArgs.Item1, cmdAndArgs.Item2);
                deletionTasks.Add(deleteTask);
            }

            Task.WaitAll(deletionTasks.ToArray());
        }
Exemple #5
0
        public void Delete <M>(List <M> modelsToDelete, IDeleteModel deleteModel) where M : IModel, new()
        {
            var queries = new string[modelsToDelete.Count];

            for (int i = 0; i < modelsToDelete.Count; i++)
            {
                queries[i] = deleteModel.GetDeleteString(modelsToDelete[i]);
            }
            var flattenedUpdateQueries = UtilityFunctions.FlattenQueries(queries);

            using (var trans = _connection.BeginTransaction())
            {
                var cmd = new CommandType()
                {
                    CommandText    = flattenedUpdateQueries,
                    Connection     = _connection,
                    CommandTimeout = 2000000
                };
                cmd.ExecuteNonQuery();

                trans.Commit();
            }
        }