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


C# Session.Execute方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:joaquincasares,项目名称:csharp-driver,代码行数:37,代码来源:MetadataTests.cs

示例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).");
 }
开发者ID:sdether,项目名称:csharp-driver,代码行数:9,代码来源:CommonBasicTests.cs

示例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.");
        }
开发者ID:sdether,项目名称:csharp-driver,代码行数:16,代码来源:CommonBasicTests.cs

示例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).");
 }
开发者ID:sdether,项目名称:csharp-driver,代码行数:9,代码来源:CommonBasicTests.cs


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