本文整理汇总了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);
}
}
示例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);
}
}
示例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();
}
}
示例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);
}
}