var keyspace = "mydb";
var datacentersReplicationFactors = new Dictionary<string, int>(0);
var replication = ReplicationStrategies.CreateNetworkTopologyStrategyReplicationProperty(datacentersReplicationFactors);
using (var cluster = Cluster.Builder().AddContactPoints("my_ip").Build())
using (var session = cluster.Connect())
{
session.CreateKeyspaceIfNotExists(keyspace, replication, true);
session.ChangeKeyspace(keyspace);
var entityTable = new Table<Models.Entity>(session);
var attributeTable = new Table<Models.Attribute>(session);
entityTable.CreateIfNotExists(); // Worked
attributeTable.CreateIfNotExists(); // Worked
entityTable.Delete(); // Does nothing
attributeTable.Delete(); // Does nothing
}
编辑:没有使用原始查询session.Execute("DROP TABLE entities;");
工作正常。如何使用C#Datastax驱动程序删除Cassandra上的表?
我得到 “行0:-1不匹配输入 '' 期待K_WHERE” –
Almis
被删除返回查询什么()? – CodeFuller
嗯,似乎这是DELETE命令,而不是DROP,我得到'{DELETE FROM entities}' – Almis