本文整理汇总了C#中Cassandra.Session.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# Session.Execute方法的具体用法?C# Session.Execute怎么用?C# Session.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cassandra.Session
的用法示例。
在下文中一共展示了Session.Execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: checkKSMetadata
public void checkKSMetadata()
{
CCMCluster = CCMBridge.CCMCluster.Create(2, Cluster.Builder());
try
{
Session = CCMCluster.Session;
Cluster = CCMCluster.Cluster;
Session.CreateKeyspaceIfNotExists(Keyspace);
Session.ChangeKeyspace(Keyspace);
string keyspacename = "keyspace" + Guid.NewGuid().ToString("N").ToLower();
bool durableWrites = false;
string strgyClass = "SimpleStrategy";
short rplctnFactor = 1;
Session.Cluster.WaitForSchemaAgreement(
Session.Execute(
string.Format(@"CREATE KEYSPACE {0}
WITH replication = {{ 'class' : '{1}', 'replication_factor' : {2} }}
AND durable_writes={3};"
, keyspacename, strgyClass, rplctnFactor.ToString(), durableWrites.ToString())).QueriedHost
);
Session.ChangeKeyspace(keyspacename);
for (int i = 0; i < 10; i++)
checkPureMetadata("table" + Guid.NewGuid().ToString("N"), keyspacename);
KeyspaceMetadata ksmd = Cluster.Metadata.GetKeyspace(keyspacename);
Assert.True(ksmd.DurableWrites == durableWrites);
Assert.True(ksmd.Replication.Where(opt => opt.Key == "replication_factor").First().Value == rplctnFactor);
Assert.True(ksmd.StrategyClass == strgyClass);
}
finally
{
CCMCluster.Discard();
}
}
示例2: ExecuteSyncNonQuery
public void ExecuteSyncNonQuery(Session session, string query, string messageInstead = null, ConsistencyLevel consistency= ConsistencyLevel.Default)
{
if (messageInstead != null)
Console.WriteLine("CQL<\t" + messageInstead);
else
Console.WriteLine("CQL< Query:\t" + query);
var ret = session.Execute(query, consistency);
Console.WriteLine("CQL> (OK).");
}
示例3: ExecuteSyncQuery
public void ExecuteSyncQuery(Session session, string query, List<object[]> expectedValues = null, ConsistencyLevel consistency = ConsistencyLevel.Default, string messageInstead = null)
{
if (messageInstead != null)
Console.WriteLine("CQL<\t" + messageInstead);
else
Console.WriteLine("CQL< Query:\t" + query);
if (expectedValues != null)
using (var ret = session.Execute(query, consistency))
valueComparator(ret, expectedValues);
using (var ret = session.Execute(query, consistency))
ret.PrintTo(stream: Console.Out, cellEncoder: CellEncoder);
Console.WriteLine("CQL> Done.");
}
示例4: ExecutePreparedQuery
public void ExecutePreparedQuery(Session session, PreparedStatement prepared, object[] values, ConsistencyLevel consistency = ConsistencyLevel.Default, string messageInstead = null)
{
if (messageInstead != null)
Console.WriteLine("CQL<\t" + messageInstead);
else
Console.WriteLine("CQL< Executing Prepared Query:\t");
session.Execute(prepared.Bind(values).SetConsistencyLevel(consistency));
Console.WriteLine("CQL> (OK).");
}