Пример #1
0
        public void Update<M>(List<M> modelsWithNewValues, IUpdateModel updateModel) where M : IModel, new()
        {
            var queries = modelsWithNewValues.Select(m => updateModel.GetUpdateString(m)).ToList();
            var batches = CreateBatches(queries);

            batches.ForEach(b =>
            {
                var task = _cassandraSession.ExecuteAsync(b);
                task.Wait();
            });
        }
        public void Update <M>(List <M> modelsWithNewValues, IUpdateModel updateModel) where M : IModel, new()
        {
            string[] updateQueries = new string[modelsWithNewValues.Count];
            for (int i = 0; i < modelsWithNewValues.Count; i++)
            {
                updateQueries[i] = updateModel.GetUpdateString(modelsWithNewValues[i]);
            }

            using (var trans = _connection.BeginTransaction())
            {
                _connection.Execute(UtilityFunctions.FlattenQueries(updateQueries), commandTimeout: Int32.MaxValue);
                trans.Commit();
            }
        }
Пример #3
0
        public void Update <M>(List <M> modelsWithNewValues, IUpdateModel updateModel) where M : IModel, new()
        {
            List <Task> updatingTasks = new List <Task>();

            foreach (var model in modelsWithNewValues)
            {
                var updateStr  = updateModel.GetUpdateString(model);
                var cmdAndArgs = this.SeparateCmdAndArguments(updateStr);

                var updateModelTask = _databaseConnection.ExecuteAsync(cmdAndArgs.Item1, cmdAndArgs.Item2);
                updatingTasks.Add(updateModelTask);
            }

            Task.WaitAll(updatingTasks.ToArray());
        }
Пример #4
0
        public void Update <M>(List <M> modelsWithNewValues, IUpdateModel updateModel) where M : IModel, new()
        {
            var queries = new string[modelsWithNewValues.Count];

            for (int i = 0; i < modelsWithNewValues.Count; i++)
            {
                queries[i] = updateModel.GetUpdateString(modelsWithNewValues[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();
            }
        }