public void CreateCollectionIfNotExists<M>(ICreateCollectionModel<M> createCollectionModel) where M : IModel, new() { if (this.GetAllTableNames().Contains(typeof(M).Name.ToLower()) == false) { var createCollectionTable = createCollectionModel.GetCreateCollectionText(); _cassandraMapper.Execute(createCollectionTable); } }
public void CreateCollectionIfNotExists <M>(ICreateCollectionModel <M> createCollectionModel) where M : IModel, new() { try { //Trying to get the amount of models of this type. Will throw an exception if the table doesn't exist var amountOfModelsOfType = this.Amount <M>(); } catch (Exception e) // table does not exist so we create it { using (var cmd = new CommandType() { CommandText = createCollectionModel.GetCreateCollectionText(), Connection = _connection, CommandTimeout = 2000000 }) { cmd.ExecuteNonQuery(); } } }