Permalink
Browse files

Added comments to make Sandbox program more readable

  • Loading branch information...
1 parent 4b0c6bb commit 018d3e596316421378938736565d995a61680aa6 @nberardi nberardi committed May 4, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 test/FluentCassandra.Sandbox/Program.cs
View
17 test/FluentCassandra.Sandbox/Program.cs
@@ -25,6 +25,8 @@ private static void SetupKeyspace()
ReplicationFactor = 1 }, db);
keyspace.TryCreateSelf();
+
+ // create column family using CQL
db.ExecuteNonQuery(@"
CREATE COLUMNFAMILY Posts (
KEY ascii PRIMARY KEY,
@@ -33,12 +35,16 @@ private static void SetupKeyspace()
Author text,
PostedOn timestamp
);");
+
+ // create column family using API
keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema {
FamilyName = "Tags",
KeyType = CassandraType.AsciiType,
ColumnNameType = CassandraType.Int32Type,
DefaultColumnValueType = CassandraType.UTF8Type
});
+
+ // create super column family using API
keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema {
FamilyName = "Comments",
FamilyType = ColumnType.Super,
@@ -153,7 +159,11 @@ private static void ReadFirstPost()
// get the post back from the database
ConsoleHeader("getting 'first-blog-post'");
+
+ // query using API
dynamic post = postFamily.Get(key).FirstOrDefault();
+
+ // query using CQL-LINQ
dynamic tags = (
from t in tagsFamily
where t.Key == key
@@ -185,7 +195,11 @@ private static void ReadAllPosts()
// get the post back from the database
ConsoleHeader("getting 'first-blog-post'");
+
+ // query using CQL
var posts = db.ExecuteQuery("SELECT * FROM Posts LIMIT 25");
+
+ // query using API
dynamic tags = tagsFamily.Get(key).FirstOrDefault();
// show details
@@ -221,6 +235,8 @@ private static void UpdateFirstPost()
// get the post back from the database
ConsoleHeader("getting 'first-blog-post' for update");
+
+ // query using API
dynamic post = postFamily.Get(key).FirstOrDefault();
post.Title = post.Title + "(updated)";
@@ -301,6 +317,7 @@ private static void ReadComments()
ConsoleHeader("showing page " + page + " of comments starting at " + lastDate.ToLocalTime());
+ // query using API
var comments = commentsFamily.Get(key)
.ReverseColumns()
.StartWithColumn(lastDate)

0 comments on commit 018d3e5

Please sign in to comment.