当前位置: 首页>>代码示例>>C#>>正文


C# CassandraContext.TryDropKeyspace方法代码示例

本文整理汇总了C#中CassandraContext.TryDropKeyspace方法的典型用法代码示例。如果您正苦于以下问题:C# CassandraContext.TryDropKeyspace方法的具体用法?C# CassandraContext.TryDropKeyspace怎么用?C# CassandraContext.TryDropKeyspace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CassandraContext的用法示例。


在下文中一共展示了CassandraContext.TryDropKeyspace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResetDatabase

        public void ResetDatabase()
        {
            using (var session = new CassandraSession(ConnectionBuilder))
            using (var db = new CassandraContext(session))
            {
                db.ThrowErrors = true;
                db.TryDropKeyspace(Keyspace);

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

                keyspace.TryCreateSelf();

                db.ExecuteNonQuery(@"
            CREATE TABLE users (
            id int ,
            name ascii,
            email ascii,
            age int,
            PRIMARY KEY(id, email)
            );");

                ResetUsersFamily(db);
            }
        }
开发者ID:smerchek,项目名称:fluentcassandra,代码行数:28,代码来源:CassandraCql3DatabaseSetup.cs

示例2: ResetDatabase

        public void ResetDatabase()
        {
            using (var session = new CassandraSession(ConnectionBuilder))
            using (var db = new CassandraContext(session))
            {
                db.ThrowErrors = true;
                db.TryDropKeyspace(Keyspace);

                var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema
                {
                    Name = Keyspace
                }, 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(new CassandraColumnFamilySchema
                {
                    FamilyName = "StandardCompositeType",
                    ColumnNameType = CassandraType.CompositeType(new[] { CassandraType.AsciiType, CassandraType.DoubleType })
                });
                keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema
                {
                    FamilyName = "StandardDynamicCompositeType",
                    ColumnNameType = CassandraType.DynamicCompositeType(new Dictionary<char, CassandraType> { { 'a', CassandraType.AsciiType }, { 'd', CassandraType.DoubleType } })
                });

                db.ExecuteNonQuery(string.Format(@"
            CREATE TABLE {0} (
            id int ,
            name ascii,
            email ascii,
            age int,
            PRIMARY KEY(id)
            );", toLowerIf(toLower, "Users")));

                //db.ExecuteNonQuery(@"CREATE INDEX User_Age ON users (Age);");
                db.Keyspace.ClearCachedKeyspaceSchema();

                var family = db.GetColumnFamily<AsciiType>("Standard");
                var superFamily = db.GetColumnFamily<AsciiType, AsciiType>("Super");
                var userFamily = db.GetColumnFamily(toLowerIf(toLower, "Users"));

                ResetFamily(family);
                ResetSuperFamily(superFamily);
                ResetUsersFamily(userFamily);
            }
        }
开发者ID:smerchek,项目名称:fluentcassandra,代码行数:57,代码来源:CompatibilityCassandraDatabaseSetup.cs

示例3: ResetDatabase

        public void ResetDatabase()
        {
            using (var session = new CassandraSession(ConnectionBuilder))
            using (var db = new CassandraContext(session))
            {
                db.ThrowErrors = true;
                db.TryDropKeyspace(Keyspace);

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

                keyspace.TryCreateSelf();

            }
        }
开发者ID:smerchek,项目名称:fluentcassandra,代码行数:18,代码来源:GenericDatabaseSetup.cs

示例4: ResetDatabase

		public void ResetDatabase()
		{
			using (var session = new CassandraSession(ConnectionBuilder))
			using (var db = new CassandraContext(session))
			{
				db.ThrowErrors = true;
				db.TryDropKeyspace(Keyspace);

				var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema {
					Name = Keyspace
				}, 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(new CassandraColumnFamilySchema() {
					FamilyName = "Counters",
					ColumnNameType = CassandraType.AsciiType,
					DefaultColumnValueType = CassandraType.CounterColumnType
				});
				keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema {
					FamilyName = "StandardDecimalType",
					ColumnNameType = CassandraType.DecimalType
				});
				keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema {
					FamilyName = "StandardCompositeType",
					ColumnNameType = CassandraType.CompositeType(new[] { CassandraType.AsciiType, CassandraType.DoubleType })
				});
				keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema {
					FamilyName = "StandardDynamicCompositeType",
					ColumnNameType = CassandraType.DynamicCompositeType(new Dictionary<char, CassandraType> { { 'a', CassandraType.AsciiType }, { 'd', CassandraType.DoubleType } })
				});

				db.ExecuteNonQuery(@"
CREATE COLUMNFAMILY Users (
	Id int PRIMARY KEY,
	Name ascii,
	Email ascii,
	Age int
);", CqlVersion.Cql);
				db.ExecuteNonQuery(@"CREATE INDEX User_Age ON Users (Age);", CqlVersion.Cql);
				db.Keyspace.ClearCachedKeyspaceSchema();

				var family = db.GetColumnFamily<AsciiType>("Standard");
				var superFamily = db.GetColumnFamily<AsciiType, AsciiType>("Super");
				var userFamily = db.GetColumnFamily("Users");
				var counterFamily = db.GetColumnFamily("Counters");

				ResetFamily(family);
				ResetSuperFamily(superFamily);
				ResetUsersFamily(userFamily);
				ResetCounterColumnFamily(counterFamily);
			}
		}
开发者ID:nathannis,项目名称:fluentcassandra,代码行数:63,代码来源:CassandraDatabaseSetup.cs


注:本文中的CassandraContext.TryDropKeyspace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。