コード例 #1
0
ファイル: Program.cs プロジェクト: rasmus-s/csharp-driver
        /// <summary>
        /// Using a typical topic/message schema, it inserts a topic, messages and retrieves them.
        /// </summary>
        public static void ForumExample()
        {
            Console.WriteLine("--------------------");
            Console.WriteLine("Executing forum sample");

            var repository = new ForumRepository(_session);
            //Add a topic
            //It will insert 2 rows in a batch
            var topicId = Guid.NewGuid();
            repository.AddTopic(topicId, "Sample forum thread", "This is the first message and body of the topic");

            //Insert some messages
            for (var i = 1; i < 250; i++)
            {
                repository.AddMessage(topicId, "Message " + (i + 1));
            }

            //Now lets retrieve the messages by topic with a page size of 20.
            var rs = repository.GetMessages(topicId, 100);
            //At this point only 100 rows are loaded into the RowSet.
            Console.WriteLine("Printing all the rows paginating with a page size of 100");
            foreach (var row in rs)
            {
                //While we iterate though the RowSet
                //We will paginate through all the rows
                Console.WriteLine(row.GetValue<string>("message_body"));
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: welly87/csharp-driver
        /// <summary>
        /// Using a typical topic/message schema, it inserts a topic, messages and retrieves them.
        /// </summary>
        public static void ForumExample()
        {
            Console.WriteLine("--------------------");
            Console.WriteLine("Executing forum sample");

            var repository = new ForumRepository(_session);
            //Add a topic
            //It will insert 2 rows in a batch
            var topicId = Guid.NewGuid();

            repository.AddTopic(topicId, "Sample forum thread", "This is the first message and body of the topic");

            //Insert some messages
            for (var i = 1; i < 250; i++)
            {
                repository.AddMessage(topicId, "Message " + (i + 1));
            }

            //Now lets retrieve the messages by topic with a page size of 20.
            var rs = repository.GetMessages(topicId, 100);

            //At this point only 100 rows are loaded into the RowSet.
            Console.WriteLine("Printing all the rows paginating with a page size of 100");
            foreach (var row in rs)
            {
                //While we iterate though the RowSet
                //We will paginate through all the rows
                Console.WriteLine(row.GetValue <string>("message_body"));
            }
        }