public void Create<M>(List<M> newModels, ICreateModel createModel) where M : IModel, new() { var queries = newModels.Select(m => createModel.GetCreateString(m)).ToList(); var batches = CreateBatches(queries); batches.ForEach(b => { var task = _cassandraSession.ExecuteAsync(b); task.Wait(); }); }
public void Create <M>(List <M> newModels, ICreateModel createModel) where M : IModel, new() { List <M> deserializedModels = new List <M>(); foreach (var model in newModels) { var createQueryText = createModel.GetCreateString(model); var deserializedVal = BsonSerializer.Deserialize <M>(createQueryText); deserializedModels.Add(deserializedVal); } _database.GetCollection <M>(nameof(M)).InsertMany(deserializedModels); }
public void Create <M>(List <M> newModels, ICreateModel createModel) where M : IModel, new() { string[] createQueries = new string[newModels.Count]; for (int i = 0; i < newModels.Count; i++) { createQueries[i] = createModel.GetCreateString(newModels[i]); } using (var trans = _connection.BeginTransaction()) { _connection.Execute(UtilityFunctions.FlattenQueries(createQueries), commandTimeout: Int32.MaxValue); trans.Commit(); } }
public void Create <M>(List <M> newModels, ICreateModel createModel) where M : IModel, new() { List <Task> creationTasks = new List <Task>(); foreach (var model in newModels) { var createStr = createModel.GetCreateString(model); var cmdAndArgs = this.SeparateCmdAndArguments(createStr); var createModelTask = _databaseConnection.ExecuteAsync(cmdAndArgs.Item1, cmdAndArgs.Item2); creationTasks.Add(createModelTask); } Task.WaitAll(creationTasks.ToArray()); }
public ShellViewModel(IEventAggregator eventAggregator, [ImportMany(typeof(ModuleViewModelBase))] IEnumerable <ModuleViewModelBase> children, ICreateModel model) { this.eventAggregator = eventAggregator; this.model = model; this.children = children.ToDictionary(c => c.ModuleType); this.DisplayName = "Cm93"; SetModels(); this.ActiveItem = this.children[ModuleType.StartScreen]; this.eventAggregator.Subscribe(this); }
public void Create <M>(List <M> newModels, ICreateModel createModel) where M : IModel, new() { var queries = new string[newModels.Count]; for (int i = 0; i < newModels.Count; i++) { queries[i] = createModel.GetCreateString(newModels[i]); } var flattenedCreateQueries = UtilityFunctions.FlattenQueries(queries); using (var trans = _connection.BeginTransaction()) { var cmd = new CommandType() { CommandText = flattenedCreateQueries, Connection = _connection, CommandTimeout = 2000000 }; cmd.ExecuteNonQuery(); trans.Commit(); } }