public void TestInit()
 {
     var setup = new CassandraDatabaseSetup();
     _db = setup.DB;
     _family = setup.UserFamily;
     _users = setup.Users;
 }
Пример #2
0
 public void TestInit()
 {
     var setup = new CassandraDatabaseSetup();
     _db = setup.DB;
     _family = setup.Family;
     _superFamily = setup.SuperFamily;
 }
        public CompatibilityCassandraDatabaseSetup(bool reset = false, bool toLower = false, bool toLower2 = false)
        {
            this.toLower = toLower;
            this.toLower2 = toLower2;

            ConnectionBuilder = new ConnectionBuilder(keyspace: Keyspace, server: Server, cqlVersion: CqlVersion.Cql3);
            DB = new CassandraContext(ConnectionBuilder);

            if (DB.KeyspaceExists(Keyspace))
                DB.DropKeyspace(Keyspace);

            var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema
            {
                Name = Keyspace,
            }, DB);

            var exists = DB.KeyspaceExists(Keyspace);
            if(!exists)
                keyspace.TryCreateSelf();

            Family = DB.GetColumnFamily<AsciiType>("Standard");
            SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");
            UserFamily = DB.GetColumnFamily(toLowerIf(toLower,"Users"));

            if (exists && !reset)
                return;

            ResetDatabase();
        }
        public void SetFixture(CassandraDatabaseSetupFixture data)
        {
            var setup = data.DatabaseSetup(cqlVersion: CqlVersion.Cql);

            _db     = setup.DB;
            _family = setup.UserFamily;
            _users  = setup.Users;
        }
Пример #5
0
        public void TestInit()
        {
            var keyspaceName = "Testing";
            var server       = new Server("localhost");

            _db     = new CassandraContext(keyspace: keyspaceName, server: server);
            _family = _db.GetColumnFamily <AsciiType>("Users");
        }
        public LinqToCqlObjectsTests()
        {
            var keyspaceName = ConfigurationManager.AppSettings["TestKeySpace"];
            var server = new Server(ConfigurationManager.AppSettings["TestServer"]);

            _db = new CassandraContext(keyspace: keyspaceName, server: server);
            _family = _db.GetColumnFamily<AsciiType>("Users");
        }
        public LinqToCqlObjectsTests()
        {
            var keyspaceName = "Testing";
            var server = new Server("localhost");

            _db = new CassandraContext(keyspace: keyspaceName, server: server);
            _family = _db.GetColumnFamily<AsciiType>("Users");
        }
Пример #8
0
		public LinqToCqlTests()
		{
			var keyspaceName = ConfigurationManager.AppSettings["TestKeySpace"];
			var server = new Server(ConfigurationManager.AppSettings["TestServer"]);

			_db = new CassandraContext(new ConnectionBuilder(keyspace: keyspaceName, server: server, cqlVersion: CqlVersion.Cql));
			_family = _db.GetColumnFamily<AsciiType>("Users");
		}
        public LinqToCqlObjectsTests()
        {
            var keyspaceName = ConfigurationManager.AppSettings["TestKeySpace"];
            var server       = new Server(ConfigurationManager.AppSettings["TestServer"]);

            _db     = new CassandraContext(keyspace: keyspaceName, server: server);
            _family = _db.GetColumnFamily <AsciiType>("Users");
        }
Пример #10
0
        public void SetFixture(CassandraDatabaseSetupFixture data)
        {
            var setup = data.DatabaseSetup();

            _db          = setup.DB;
            _family      = setup.Family;
            _superFamily = setup.SuperFamily;
        }
Пример #11
0
        public LinqToCqlTests()
        {
            var keyspaceName = ConfigurationManager.AppSettings["TestKeySpace"];
            var server       = new Server(ConfigurationManager.AppSettings["TestServer"]);

            _db     = new CassandraContext(new ConnectionBuilder(keyspace: keyspaceName, server: server, cqlVersion: CqlVersion.Cql));
            _family = _db.GetColumnFamily <AsciiType>("Users");
        }
Пример #12
0
        public void TestInit()
        {
            var setup = new _CassandraSetup();

            _db          = setup.DB;
            _family      = setup.Family;
            _superFamily = setup.SuperFamily;
        }
        public void ResetCounterColumnFamily(CassandraColumnFamily counterFamily = null)
        {
            counterFamily = counterFamily ?? CounterFamily;

            counterFamily.RemoveAllRows();

            counterFamily.InsertCounterColumn(TestKey1, "Test1", 1);
            counterFamily.InsertCounterColumn(TestKey1, "Test2", 2);
            counterFamily.InsertCounterColumn(TestKey1, "Test3", 3);

            counterFamily.InsertCounterColumn(TestKey2, "Test1", 2);
            counterFamily.InsertCounterColumn(TestKey2, "Test2", 4);
            counterFamily.InsertCounterColumn(TestKey2, "Test3", 6);
        }
        public void ResetUsersFamily(CassandraColumnFamily userFamily = null)
        {
            userFamily = userFamily ?? UserFamily;

            var db = userFamily.Context;

            userFamily.RemoveAllRows();

            foreach (var user in Users)
            {
                var insertQuery = @"INSERT INTO ""Users"" (Id, Name, Email, Age) VALUES (" + user.Id + ", '" + user.Name + "', '" + user.Email + "', " + user.Age + ")";
                db.ExecuteNonQuery(insertQuery);
            }
        }
        public void ResetFamily(CassandraColumnFamily family = null)
        {
            family = family ?? Family;

            family.RemoveAllRows();

            family.InsertColumn(TestKey1, "Test1", Math.PI);
            family.InsertColumn(TestKey1, "Test2", Math.PI);
            family.InsertColumn(TestKey1, "Test3", Math.PI);

            family.InsertColumn(TestKey2, "Test1", Math.PI);
            family.InsertColumn(TestKey2, "Test2", Math.PI);
            family.InsertColumn(TestKey2, "Test3", Math.PI);
        }
Пример #16
0
        protected override void Setup()
        {
            base.Setup();

            if (!Keyspace.ColumnFamilyExists(Server, FamilyName))
                Keyspace.AddColumnFamily(Server, new CfDef {
                    Name = FamilyName,
                    Keyspace = KeyspaceName,
                    Column_type = "Standard",
                    Comparator_type = "AsciiType",
                    Comment = "Holds the blog posts"
                });

            _family = Database.GetColumnFamily<AsciiType>(FamilyName);
        }
Пример #17
0
        public _CassandraSetup()
        {
            var keyspaceName = "Testing";
            var server = new Server("localhost");

            if (CassandraSession.KeyspaceExists(server, keyspaceName))
                CassandraSession.DropKeyspace(server, keyspaceName);

            var keyspace = new CassandraKeyspace(keyspaceName);
            keyspace.TryCreateSelf(server);
            keyspace.TryCreateColumnFamily<AsciiType>(server, "Standard");
            keyspace.TryCreateColumnFamily<AsciiType, AsciiType>(server, "Super");
            keyspace.TryCreateColumnFamily<AsciiType>(server, "StandardAsciiType");
            keyspace.TryCreateColumnFamily<BytesType>(server, "StandardBytesType");
            keyspace.TryCreateColumnFamily<IntegerType>(server, "StandardIntegerType");
            keyspace.TryCreateColumnFamily<LexicalUUIDType>(server, "StandardLexicalUUIDType");
            keyspace.TryCreateColumnFamily<LongType>(server, "StandardLongType");
            keyspace.TryCreateColumnFamily<TimeUUIDType>(server, "StandardTimeUUIDType");
            keyspace.TryCreateColumnFamily<UTF8Type>(server, "StandardUTF8Type");
            keyspace.TryCreateColumnFamily<UUIDType>(server, "StandardUUIDType");
            keyspace.TryCreateColumnFamily<CompositeType<LongType, UTF8Type>>(server, "StandardCompositeType");
            keyspace.TryCreateColumnFamily<DynamicCompositeType>(server, "StandardDynamicCompositeType");

            DB = new CassandraContext(keyspaceName, server);
            DB.ThrowErrors = true;

            Family = DB.GetColumnFamily<AsciiType>("Standard");
            SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");

            Family.RemoveAllRows();
            SuperFamily.RemoveAllRows();

            Family.InsertColumn(TestKey1, "Test1", Math.PI);
            Family.InsertColumn(TestKey1, "Test2", Math.PI);
            Family.InsertColumn(TestKey1, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test3", Math.PI);

            Family.InsertColumn(TestKey2, "Test1", Math.PI);
            Family.InsertColumn(TestKey2, "Test2", Math.PI);
            Family.InsertColumn(TestKey2, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);
        }
		public CassandraDatabaseSetup(bool reset = false)
		{
			ConnectionBuilder = new ConnectionBuilder(keyspace: Keyspace, server: Server);
			DB = new CassandraContext(ConnectionBuilder);
			
			var exists = DB.KeyspaceExists(Keyspace);

			Family = DB.GetColumnFamily<AsciiType>("Standard");
			SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");
			UserFamily = DB.GetColumnFamily("Users");

			if (exists && !reset)
				return;

			ResetDatabase();
		}
Пример #19
0
        protected override void Setup()
        {
            base.Setup();

            if (!Keyspace.ColumnFamilyExists(Server, FamilyName))
            {
                Keyspace.AddColumnFamily(Server, new CfDef {
                    Name            = FamilyName,
                    Keyspace        = KeyspaceName,
                    Column_type     = "Standard",
                    Comparator_type = "AsciiType",
                    Comment         = "Holds the blog posts"
                });
            }

            _family = Database.GetColumnFamily <AsciiType>(FamilyName);
        }
        public CassandraDatabaseSetup(bool reset = false, string cqlVersion = CqlVersion.Edge)
        {
            ConnectionBuilder = new ConnectionBuilder(keyspace: Keyspace, server: Server, cqlVersion: cqlVersion);
            DB = new CassandraContext(ConnectionBuilder);

            var exists = DB.KeyspaceExists(Keyspace);

            Family        = DB.GetColumnFamily <AsciiType>("Standard");
            SuperFamily   = DB.GetColumnFamily <AsciiType, AsciiType>("Super");
            UserFamily    = DB.GetColumnFamily("Users");
            CounterFamily = DB.GetColumnFamily("Counters");

            if (exists && !reset)
            {
                return;
            }

            ResetDatabase();
        }
        public void ResetUsersFamily(CassandraColumnFamily userFamily = null)
        {
            userFamily = userFamily ?? UserFamily;

            var db = userFamily.Context;

            userFamily.RemoveAllRows();

            foreach (var user in Users)
            {
                dynamic record = userFamily.CreateRecord(user.Id);
                record.Name  = user.Name;
                record.Email = user.Email;
                record.Age   = user.Age;

                db.Attach(record);
            }

            db.SaveChanges();
        }
        public void Init()
        {
            _context = new CassandraContext(keyspace: DummiesKeySpace, host: "localhost");
            if (!_context.KeyspaceExists(DummiesKeySpace))
            {
                var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema
                {
                    Name = DummiesKeySpace,
                }, _context);
                keyspace.TryCreateSelf();
                _context.ExecuteQuery(
                    @"
                CREATE COLUMNFAMILY Dummies (
                KEY ascii PRIMARY KEY,
                Blob blob
                );");
                _context.SaveChanges();
            }

            _dummies = _context.GetColumnFamily("Dummies");
        }
        public void Init()
        {
            _context = new CassandraContext(keyspace: DummiesKeySpace, host: "localhost");
            if (!_context.KeyspaceExists(DummiesKeySpace))
            {
                var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema
                {
                    Name = DummiesKeySpace,
                }, _context);
                keyspace.TryCreateSelf();
                _context.ExecuteQuery(
                    @"
                CREATE COLUMNFAMILY Dummies (
	            KEY ascii PRIMARY KEY,
	            Blob blob
                );");
                _context.SaveChanges();
            }

            _dummies = _context.GetColumnFamily("Dummies");
        }
Пример #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CqlQuery&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="expression">The expression.</param>
 /// <param name="provider">The provider.</param>
 public CqlObjectQuery(Expression expression, IQueryProvider provider, CassandraColumnFamily family)
 {
     _expression = expression;
     _provider   = provider;
     _family     = family;
 }
Пример #25
0
        public _CassandraSetup()
        {
            var keyspaceName = "Testing";
            var server       = new Server("localhost");

            if (!CassandraSession.KeyspaceExists(server, keyspaceName))
            {
                CassandraSession.AddKeyspace(server, new KsDef {
                    Name = "Testing",
                    Replication_factor = 1,
                    Strategy_class     = "org.apache.cassandra.locator.SimpleStrategy",
                    Cf_defs            = new List <CfDef>()
                });
            }

            var keyspace = new CassandraKeyspace(keyspaceName);

            if (!keyspace.ColumnFamilyExists(server, "Standard"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "Standard",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "AsciiType",
                    Comment         = "Used for testing Standard family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardAsciiType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardAsciiType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "AsciiType",
                    Comment         = "Used for testing Standard family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardBytesType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardBytesType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "BytesType",
                    Comment         = "Used for testing BytesType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardIntegerType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardIntegerType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "IntegerType",
                    Comment         = "Used for testing IntegerType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardLexicalUUIDType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardLexicalUUIDType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "LexicalUUIDType",
                    Comment         = "Used for testing LexicalUUIDType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardLongType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardLongType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "LongType",
                    Comment         = "Used for testing LongType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardTimeUUIDType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardTimeUUIDType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "TimeUUIDType",
                    Comment         = "Used for testing TimeUUIDType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardUTF8Type"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardUTF8Type",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "UTF8Type",
                    Comment         = "Used for testing UTF8Type family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "Super"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name               = "Super",
                    Keyspace           = "Testing",
                    Column_type        = "Super",
                    Comparator_type    = "AsciiType",
                    Subcomparator_type = "AsciiType",
                    Comment            = "Used for testing Super family."
                });
            }

            DB             = new CassandraContext(keyspaceName, server);
            DB.ThrowErrors = true;

            Family      = DB.GetColumnFamily <AsciiType>("Standard");
            SuperFamily = DB.GetColumnFamily <AsciiType, AsciiType>("Super");

            Family.RemoveAllRows();
            SuperFamily.RemoveAllRows();

            Family.InsertColumn(TestKey1, "Test1", Math.PI);
            Family.InsertColumn(TestKey1, "Test2", Math.PI);
            Family.InsertColumn(TestKey1, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test3", Math.PI);

            Family.InsertColumn(TestKey2, "Test1", Math.PI);
            Family.InsertColumn(TestKey2, "Test2", Math.PI);
            Family.InsertColumn(TestKey2, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);
        }
Пример #26
0
        public _CassandraSetup()
        {
            var keyspaceName = "Testing";
            var server = new Server("localhost");

            if (!CassandraSession.KeyspaceExists(server, keyspaceName))
                CassandraSession.AddKeyspace(server, new KsDef {
                    Name = "Testing",
                    Replication_factor = 1,
                    Strategy_class = "org.apache.cassandra.locator.SimpleStrategy",
                    Cf_defs = new List<CfDef>()
                });

            var keyspace = new CassandraKeyspace(keyspaceName);

            if (!keyspace.ColumnFamilyExists(server, "Standard"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "Standard",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "AsciiType",
                    Comment = "Used for testing Standard family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardAsciiType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardAsciiType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "AsciiType",
                    Comment = "Used for testing Standard family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardBytesType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardBytesType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "BytesType",
                    Comment = "Used for testing BytesType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardIntegerType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardIntegerType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "IntegerType",
                    Comment = "Used for testing IntegerType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardLexicalUUIDType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardLexicalUUIDType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "LexicalUUIDType",
                    Comment = "Used for testing LexicalUUIDType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardLongType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardLongType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "LongType",
                    Comment = "Used for testing LongType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardTimeUUIDType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardTimeUUIDType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "TimeUUIDType",
                    Comment = "Used for testing TimeUUIDType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardUTF8Type"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardUTF8Type",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "UTF8Type",
                    Comment = "Used for testing UTF8Type family."
                });

            if (!keyspace.ColumnFamilyExists(server, "Super"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "Super",
                    Keyspace = "Testing",
                    Column_type = "Super",
                    Comparator_type = "AsciiType",
                    Subcomparator_type = "AsciiType",
                    Comment = "Used for testing Super family."
                });

            DB = new CassandraContext(keyspaceName, server);
            DB.ThrowErrors = true;

            Family = DB.GetColumnFamily<AsciiType>("Standard");
            SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");

            Family.RemoveAllRows();
            SuperFamily.RemoveAllRows();

            Family.InsertColumn(TestKey1, "Test1", Math.PI);
            Family.InsertColumn(TestKey1, "Test2", Math.PI);
            Family.InsertColumn(TestKey1, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test3", Math.PI);

            Family.InsertColumn(TestKey2, "Test1", Math.PI);
            Family.InsertColumn(TestKey2, "Test2", Math.PI);
            Family.InsertColumn(TestKey2, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);
        }
        public CassandraDatabaseSetup(bool volitile = false)
        {
            var keyspaceName = "Testing";
            var server = new Server("localhost");

            DB = new CassandraContext(keyspaceName, server);
            DB.ThrowErrors = true;

            var exists = DB.KeyspaceExists(keyspaceName);
            Users = new[] {
                new User { Id = 1, Name = "Darren Gemmell", Email = "*****@*****.**", Age = 32 },
                new User { Id = 2, Name = "Fernando Laubscher", Email = "*****@*****.**", Age = 23 },
                new User { Id = 3, Name = "Cody Millhouse", Email = "*****@*****.**", Age = 56 },
                new User { Id = 4, Name = "Emilia Thibert", Email = "*****@*****.**", Age = 67 },
                new User { Id = 5, Name = "Allyson Schurr", Email = "*****@*****.**", Age = 21 }
            };

            Family = DB.GetColumnFamily<AsciiType>("Standard");
            SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");
            UserFamily = DB.GetColumnFamily("Users");

            if (exists && !volitile)
                return;

            using (var session = DB.OpenSession())
            {
                if (exists)
                    DB.DropKeyspace(keyspaceName);

                var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema { Name = keyspaceName, Strategy = CassandraKeyspaceSchema.ReplicaPlacementStrategySimple, ReplicationFactor = 1 }, DB);
                DB.Keyspace = keyspace;

                keyspace.TryCreateSelf();
                keyspace.TryCreateColumnFamily<AsciiType>("Standard");
                keyspace.TryCreateColumnFamily<AsciiType, AsciiType>("Super");
                keyspace.TryCreateColumnFamily<AsciiType>("StandardAsciiType");
                keyspace.TryCreateColumnFamily<BytesType>("StandardBytesType");
                keyspace.TryCreateColumnFamily<IntegerType>("StandardIntegerType");
                keyspace.TryCreateColumnFamily<LexicalUUIDType>("StandardLexicalUUIDType");
                keyspace.TryCreateColumnFamily<LongType>("StandardLongType");
                keyspace.TryCreateColumnFamily<TimeUUIDType>("StandardTimeUUIDType");
                keyspace.TryCreateColumnFamily<UTF8Type>("StandardUTF8Type");
                keyspace.TryCreateColumnFamily<UUIDType>("StandardUUIDType");
                keyspace.TryCreateColumnFamily<CompositeType<LongType, UTF8Type>>("StandardCompositeType");
                keyspace.TryCreateColumnFamily<DynamicCompositeType>("StandardDynamicCompositeType");

                Family = DB.GetColumnFamily<AsciiType>("Standard");
                SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");

                Family.InsertColumn(TestKey1, "Test1", Math.PI);
                Family.InsertColumn(TestKey1, "Test2", Math.PI);
                Family.InsertColumn(TestKey1, "Test3", Math.PI);

                SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test1", Math.PI);
                SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test2", Math.PI);
                SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test3", Math.PI);

                Family.InsertColumn(TestKey2, "Test1", Math.PI);
                Family.InsertColumn(TestKey2, "Test2", Math.PI);
                Family.InsertColumn(TestKey2, "Test3", Math.PI);

                SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test1", Math.PI);
                SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
                SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);

                DB.ExecuteNonQuery(@"
            CREATE COLUMNFAMILY Users (
            KEY int PRIMARY KEY,
            Name ascii,
            Email ascii,
            Age int
            );");
                DB.ExecuteNonQuery(@"CREATE INDEX User_Age ON Users (Age);");
                DB.Keyspace.ClearCachedKeyspaceSchema();
                UserFamily = DB.GetColumnFamily("Users");

                foreach (var user in Users)
                {
                    dynamic record = UserFamily.CreateRecord(user.Id);
                    record.Name = user.Name;
                    record.Email = user.Email;
                    record.Age = user.Age;

                    DB.Attach(record);
                }
                DB.SaveChanges();
            }
        }
Пример #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CqlQuery&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="expression">The expression.</param>
 /// <param name="provider">The provider.</param>
 public CqlQuery(Expression expression, CassandraColumnFamily provider)
 {
     _expression = expression;
     _provider   = provider;
 }
 public CqlObjectQueryProvider(CassandraColumnFamily family)
 {
     _family = family;
 }
		public void ResetFamily(CassandraColumnFamily family = null)
		{
			family = family ?? Family;

			family.RemoveAllRows();

			family.InsertColumn(TestKey1, "Test1", Math.PI);
			family.InsertColumn(TestKey1, "Test2", Math.PI);
			family.InsertColumn(TestKey1, "Test3", Math.PI);

			family.InsertColumn(TestKey2, "Test1", Math.PI);
			family.InsertColumn(TestKey2, "Test2", Math.PI);
			family.InsertColumn(TestKey2, "Test3", Math.PI);
		}
		public void ResetUsersFamily(CassandraColumnFamily userFamily = null)
		{
			userFamily = userFamily ?? UserFamily;

			var db = userFamily.Context;
			userFamily.RemoveAllRows();

			foreach (var user in Users)
			{
				dynamic record = userFamily.CreateRecord(user.Id);
				record.Name = user.Name;
				record.Email = user.Email;
				record.Age = user.Age;

				db.Attach(record);
			}

			db.SaveChanges();
		}
		public void ResetUsersFamily(CassandraColumnFamily userFamily = null)
		{
			userFamily = userFamily ?? UserFamily;

			var db = userFamily.Context;
			userFamily.RemoveAllRows();

			foreach (var user in Users)
			{
                var insertQuery = @"INSERT INTO ""Users"" (Id, Name, Email, Age) VALUES ("+ user.Id +", '" + user.Name + "', '"+ user.Email +"', "+ user.Age +")";
                db.ExecuteNonQuery(insertQuery);
			}
		}
		public void ResetCounterColumnFamily(CassandraColumnFamily counterFamily = null)
		{
			counterFamily = counterFamily ?? CounterFamily;

			counterFamily.RemoveAllRows();

			counterFamily.InsertCounterColumn(TestKey1, "Test1", 1);
			counterFamily.InsertCounterColumn(TestKey1, "Test2", 2);
			counterFamily.InsertCounterColumn(TestKey1, "Test3", 3);

			counterFamily.InsertCounterColumn(TestKey2, "Test1", 2);
			counterFamily.InsertCounterColumn(TestKey2, "Test2", 4);
			counterFamily.InsertCounterColumn(TestKey2, "Test3", 6);
		}
 private void AddTable <CompareWith>(CassandraColumnFamily <CompareWith> provider)
     where CompareWith : CassandraType
 {
     _columnFamily = provider.FamilyName;
 }
 public void TestInit()
 {
     var setup = new _CassandraSetup();
     _db = setup.DB;
     _family = setup.Family;
 }
Пример #36
0
 private void AddTable(CassandraColumnFamily provider)
 {
     _columnFamily = provider.FamilyName;
 }