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


C# ISession.Execute方法代码示例

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


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

示例1: SetupFixture

 public void SetupFixture()
 {
     Diagnostics.CassandraTraceSwitch.Level = TraceLevel.Info;
     //Using a mirroring handler, the server will reply providing the same payload that was sent
     var jvmArgs = new [] { "-Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler" };
     var testCluster = TestClusterManager.GetTestCluster(1, 0, false, DefaultMaxClusterCreateRetries, true, true, 0, jvmArgs);
     Session = testCluster.Session;
     Session.Execute(String.Format(TestUtils.CreateKeyspaceSimpleFormat, Keyspace, 1));
     Session.Execute(String.Format(TestUtils.CreateTableSimpleFormat, Table));
 }
开发者ID:raideroflostark,项目名称:csharp-driver,代码行数:10,代码来源:CustomPayloadTests.cs

示例2: CreateMultiDcSchema

 public void CreateMultiDcSchema(ISession session, int dc1RF = 1, int dc2RF = 1)
 {
     session.Execute(String.Format(TestUtils.CreateKeyspaceGenericFormat, DefaultKeyspace, "NetworkTopologyStrategy",
                                       string.Format("'dc1' : {0}, 'dc2' : {1}", dc1RF, dc2RF)));
     TestUtils.WaitForSchemaAgreement(session.Cluster);
     session.ChangeKeyspace(DefaultKeyspace);
     TestUtils.WaitForSchemaAgreement(session.Cluster);
     session.Execute(String.Format("CREATE TABLE {0} (k int PRIMARY KEY, i int)", TableName));
     TestUtils.WaitForSchemaAgreement(session.Cluster);
 }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:10,代码来源:PolicyTestTools.cs

示例3: Execute

        public void Execute(ISession session)
        {
            if (_animal.Id > 0)
            {
                session.Execute("UPDATE Animals SET Name = @Name, CommonName = @CommonName WHERE Id = @Id", new { _animal.Id, _animal.Name, _animal.CommonName });
                return;
            }

            session.Execute("INSERT INTO Animals (Name, CommonName) VALUES (@Name, @CommonName)", new { _animal.Name, _animal.CommonName });
        }
开发者ID:upnxt,项目名称:upnxt-dapper-cqrs,代码行数:10,代码来源:SaveAnimal.cs

示例4: TestFixtureSetUp

        protected override void TestFixtureSetUp()
        {
            if (CassandraVersion < Version.Parse("2.1.0"))
                Assert.Ignore("Requires Cassandra version >= 2.1");
            
            base.TestFixtureSetUp();
            _session = Session;

            _session.Execute(String.Format(TestUtils.CreateKeyspaceSimpleFormat, _uniqueKeyspaceName, 1));
            _session.ChangeKeyspace(_uniqueKeyspaceName);
            _session.Execute("CREATE TYPE song (id uuid, title text, artist text)");
            _session.UserDefinedTypes.Define(UdtMap.For<Song>());
        }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:13,代码来源:LinqUdtTests.cs

示例5: CreateSchema

 public void CreateSchema(ISession session, int replicationFactor)
 {
     try
     {
         session.Execute(String.Format(TestUtils.CreateKeyspaceSimpleFormat, DefaultKeyspace, replicationFactor));
     }
     catch (AlreadyExistsException)
     {
     }
     TestUtils.WaitForSchemaAgreement(session.Cluster);
     session.ChangeKeyspace(DefaultKeyspace);
     session.Execute(String.Format("CREATE TABLE {0} (k int PRIMARY KEY, i int)", TableName));
     TestUtils.WaitForSchemaAgreement(session.Cluster);
 }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:14,代码来源:PolicyTestTools.cs

示例6: TestFixtureSetUp

        protected override void TestFixtureSetUp()
        {
            base.TestFixtureSetUp();
            _session = Session;

            _session.Execute(String.Format(TestUtils.CreateKeyspaceSimpleFormat, _uniqueKeyspaceName, 1));
            _session.ChangeKeyspace(_uniqueKeyspaceName);
            _session.Execute("CREATE TYPE song (id uuid, title text, artist text)");
            _session.Execute("CREATE TABLE albums (id uuid primary key, name text, songs list<frozen<song>>, publishingdate timestamp)");
            _session.Execute(
                new SimpleStatement(
                    "INSERT INTO albums (id, name, songs) VALUES (?, 'Legend', [{id: uuid(), title: 'Africa Unite', artist: 'Bob Marley'}])",
                    _sampleId));
            _session.UserDefinedTypes.Define(UdtMap.For<Song>());
        }
开发者ID:GoldenCrystal,项目名称:csharp-driver,代码行数:15,代码来源:LinqUdtTests.cs

示例7: GetInsertAction

 public Action GetInsertAction(ISession session, object bindableStatement, ConsistencyLevel consistency, int rowsPerId)
 {
     Action action = () =>
     {
         Trace.TraceInformation("Starting inserting from thread {0}", Thread.CurrentThread.ManagedThreadId);
         var id = Guid.NewGuid();
         for (var i = 0; i < rowsPerId; i++)
         {
             var paramsArray = new object[] { id, DateTime.Now, DateTime.Now.ToString() };
             IStatement statement = null;
             if (bindableStatement is SimpleStatement)
             {
                 statement = ((SimpleStatement)bindableStatement).Bind(paramsArray).SetConsistencyLevel(consistency);
             }
             else if (bindableStatement is PreparedStatement)
             {
                 statement = ((PreparedStatement)bindableStatement).Bind(paramsArray).SetConsistencyLevel(consistency);
             }
             else
             {
                 throw new Exception("Can not bind a statement of type " + bindableStatement.GetType().FullName);
             }
             session.Execute(statement);
         }
         Trace.TraceInformation("Finished inserting from thread {0}", Thread.CurrentThread.ManagedThreadId);
     };
     return action;
 }
开发者ID:rasmus-s,项目名称:csharp-driver,代码行数:28,代码来源:StressTests.cs

示例8: AssertCanQuery

 private static void AssertCanQuery(ISession session)
 {
     for (var i = 0; i < 10; i++)
     {
         Assert.DoesNotThrow(() => session.Execute("SELECT key FROM system.local"));
     }
 }
开发者ID:datastax,项目名称:csharp-driver-dse,代码行数:7,代码来源:DsePlainTextAuthProviderTests.cs

示例9: ExecuteSyncQuery

 internal static void ExecuteSyncQuery(ISession session, string query, ConsistencyLevel consistency, List<object[]> expectedValues = null,
                                       string messageInstead = null)
 {   
     var ret = session.Execute(query, consistency);
     if (expectedValues != null)
     {
         valueComparator(ret, expectedValues);
     }
 }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:9,代码来源:QueryTools.cs

示例10: CreateForumTables

        public static void CreateForumTables(ISession session)
        {
            var createTopicCql = @"
                CREATE TABLE driver_samples_kp.topics (
                    topic_id uuid PRIMARY KEY,
                    topic_title text,
                    topic_date timestamp
                )";
            session.Execute(createTopicCql);

            var createMessageCql = @"
                CREATE TABLE driver_samples_kp.messages (
                    topic_id uuid,
                    message_date timestamp,
                    message_body text,
                    PRIMARY KEY (topic_id, message_date)
                )";
            session.Execute(createMessageCql);
        }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:19,代码来源:SchemaHelper.cs

示例11: GetSelectAction

 public Action GetSelectAction(ISession session, string query, ConsistencyLevel consistency, int executeLength)
 {
     Action action = () =>
     {
         for (var i = 0; i < executeLength; i++)
         {
             var rs = session.Execute(new SimpleStatement(query).SetPageSize(500).SetConsistencyLevel(consistency).SetRetryPolicy(DowngradingConsistencyRetryPolicy.Instance));
             //Count will iterate through the result set and it will likely to page results
             //Assert.True(rs.Count() > 0);
         }
     };
     return action;
 }
开发者ID:rasmus-s,项目名称:csharp-driver,代码行数:13,代码来源:StressTests.cs

示例12: CreateTimeSeriesTable

 private static void CreateTimeSeriesTable(ISession session)
 {
     //These are not the codez you are looking for ...
     //Boring code just intended to create the schema
     var createCql = @"
         CREATE TABLE driver_samples_kp.temperature_by_day (
            weatherstation_id text,
            date text,
            event_time timestamp,
            temperature decimal,
            PRIMARY KEY ((weatherstation_id,date),event_time)
         )";
     session.Execute(createCql);
 }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:14,代码来源:SchemaHelper.cs

示例13: SetupSessionAndCluster

        private ITestCluster SetupSessionAndCluster(int nodes, Dictionary<string, string> replication = null)
        {
            ITestCluster testCluster = TestClusterManager.GetTestCluster(nodes);
            _session = testCluster.Session;
            _ksName = TestUtils.GetUniqueKeyspaceName();
            _session.CreateKeyspace(_ksName, replication);
            TestUtils.WaitForSchemaAgreement(_session.Cluster);
            _session.ChangeKeyspace(_ksName);
            _table = new Table<ManyDataTypesEntity>(_session, new MappingConfiguration());
            _table.Create();
            _defaultPocoList = ManyDataTypesEntity.GetDefaultAllDataTypesList();
            _preparedStatement = _session.Prepare(_preparedInsertStatementAsString);
            foreach (var manyDataTypesEntity in _defaultPocoList)
                _session.Execute(GetBoundInsertStatementBasedOnEntity(manyDataTypesEntity));

            return testCluster;
        }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:17,代码来源:ConsistencyTests.cs

示例14: doInsertTrack

        /*
         * Function to attempt log in to a user account
         * @PARAMETERS: - song: the song to add
         * @RETURNS: The User who has been logged in - null if unsuccesful
         * @AUTHORS: Andrew Davis and Matt Malone
         * NOTE - Commented code left in by Matt - just in case it breaks
         */
        public bool doInsertTrack(Song song, ISession session)
        {
            try
            {
                // Call to initialise cluster connection
                //init();

                ///

                Guid tid = song.getSongID();
                String artist = song.getArtist();
                String album = song.getAlbum();
                int year = song.getYear();
                String genre = song.getGenre();
                String file_loc = song.getFileLocation();
                int length = song.getLength();
                String trackname = song.getTrackName();

                // Connect to cluster
                //ISession session = cluster.Connect("maltmusic");

                //Guid tid = Guid.NewGuid();

                // Prepare and bind statement passing in username
                String todo = ("insert into tracks (\n" +
                  "track_id, artist, album, year,genre, file_loc,length,track_name)\n" +
                 "values (:tid, :art,:alb,:yr,:gnr,:floc,:len,:tnm) if not exists");

                PreparedStatement ps = session.Prepare(todo);

                BoundStatement bs = ps.Bind(tid, artist, album, year, genre, file_loc, length, trackname);

                // Execute Query
                session.Execute(bs);
                //session.Dispose();
                return true;

                // Catch exceptions
            }
            catch (Exception ex)
            {
                Console.WriteLine("SOMETHING WENT WRONG in INSERT TRACK: " + ex.Message);
                return false;
            }
        }
开发者ID:andrewdavis1995,项目名称:MALTMusic,代码行数:52,代码来源:SongModel.cs

示例15: CreateSchemaIfNotExists

        /// <summary>
        /// Creates the schema if it doesn't exist.
        /// </summary>
        public static void CreateSchemaIfNotExists(ISession session)
        {
            var cqlStatements = new List<string>();

            // Read the CQL script in from the embedded resource
            using (var stream = CqlAssembly.GetManifestResourceStream(CqlScript))
            {
                if (stream == null)
                    throw new InvalidOperationException(string.Format("Could not find CQL script resource {0}", CqlScript));

                using (var reader = new StreamReader(stream))
                {
                    string currentLine;
                    var cqlStatement = new StringBuilder();
                    while ((currentLine = reader.ReadLine()) != null)
                    {
                        // Do some basic parsing
                        currentLine = currentLine.Trim();
                        
                        // Skip comment lines and empty lines
                        if (currentLine.StartsWith("//") || currentLine == string.Empty)
                            continue;

                        // Add line to current cql statement
                        cqlStatement.AppendFormat("{0} ", currentLine);

                        // If the line ends with a semi-colon, consider it the end of the statement
                        if (currentLine.EndsWith(";"))
                        {
                            cqlStatements.Add(cqlStatement.ToString());
                            cqlStatement.Clear();
                        }
                    }
                }
            }

            // Execute the CQL statements we parsed to create the schema
            foreach (string cql in cqlStatements)
            {
                session.Execute(cql);
            }
        }
开发者ID:AtwooTM,项目名称:AspNet.Identity.Cassandra,代码行数:45,代码来源:SchemaCreationHelper.cs


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