Created
February 13, 2012 00:59
-
-
Save kellabyte/1812314 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using FluentCassandra; | |
| using FluentCassandra.Types; | |
| namespace CassandraGettingStartedSample | |
| { | |
| class FluentCassandraSample | |
| { | |
| public static void GetPosts() | |
| { | |
| Console.WriteLine("Getting posts with FluentCassandra..."); | |
| using (var db = new CassandraContext(keyspace: "blog", host: "localhost")) | |
| { | |
| var family = db.GetColumnFamily<UTF8Type>("posts"); | |
| dynamic posts = family.Get("1").Take(25); | |
| foreach (var post in posts) | |
| { | |
| string user = post["user"]; | |
| string text = post["text"]; | |
| Console.WriteLine(string.Format("User: {0}\tText: {1}", | |
| user, | |
| text)); | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think what you want is this.
dynamic posts = family.Get("1").Get(startKey: "1", endKey: null, startToken: null, endToken: null, keyCount:25);
That is the odd thing about Cassandra, normal database paging is by rows, but all the Cassandra API's are setup to page by columns. I have been trying to find an elegant way to make this work but have't had much luck.
Luckily they are moving towards CQL http://www.datastax.com/docs/1.0/references/cql/index which I can easily wrap into LINQ. This is how you would do it in CQL.