Skip to content

Instantly share code, notes, and snippets.

@kellabyte
Created February 13, 2012 00:59
Show Gist options
  • Select an option

  • Save kellabyte/1812314 to your computer and use it in GitHub Desktop.

Select an option

Save kellabyte/1812314 to your computer and use it in GitHub Desktop.
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));
}
}
}
}
}
@nberardi

Copy link
Copy Markdown

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.

SELECT * FROM posts WHERE KEY > '1' LIMIT 25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment