private void InitDatabaseAndTable()
        {
            foreach (var adapter in EntityAdapters)
            {
                var cluster = Cluster.Builder()
                              .AddContactPoints(ConnectString)
                              .Build();

                var session = cluster.Connect();
                EntitySessions.AddOrUpdate(adapter.Key, session);
                session.CreateKeyspaceIfNotExists(adapter.Value.Table.Database);
                session.ChangeKeyspace(adapter.Value.Table.Database);
                //session.Execute($"DROP table {adapter.Value.Table.Database}.{adapter.Value.Table.Name};");
                session.Execute(GenerateCreateTableSql(adapter.Value));
                //session.Execute(GenerateCreateIndexes(adapter.Value));
            }
        }
Exemplo n.º 2
0
        private void InitDatabaseAndTable()
        {
            foreach (var adapter in EntityAdapters)
            {
                var cluster = Cluster.Builder()
                              .AddContactPoints(ConnectString)
                              .Build();

                var session = cluster.Connect();
                session.CreateKeyspaceIfNotExists(adapter.Value.Table.Database);
                session.ChangeKeyspace(adapter.Value.Table.Database);
                session.Execute(GenerateCreateTableSql(adapter.Value));
                var createIndexCql = GenerateCreateIndexes(adapter.Value);
                if (!string.IsNullOrEmpty(createIndexCql))
                {
                    session.Execute(createIndexCql);
                }
                EntitySessions.AddOrUpdate(adapter.Key, session);
            }
        }