managedfusion/fluentcassandra — Issue #16: Followed the First Fluent Cassandra example, but not get through
Author: JackinLost
Created: 2011-12-16 14:08:34+00:00
State: open

Hello @nberardi

I followed "Your First Fluent Cassandra" example, with some modification (the article is creating a super-column, but I only need column), but it gave an exception of Apache.Cassandra.Unavailable.

Could you please have a look at my simple class file? I am using Cassandra 1.0.6 by the way.

Thanks

======================

public class CassandraAPI
{
private CassandraContext cassandraDB;
private CassandraColumnFamily family;
public CassandraAPI()
{
cassandraDB = new CassandraContext(keyspace: "MyKeyspace", host: "192.168.178.32");
family = cassandraDB.GetColumnFamily("ColumnFamilyName");

}

public void update(byte[] key1, byte[] value)
{
dynamic post = family.CreateRecord(key: key1);
post.value = value;
// attach the post to the database
Console.WriteLine("attaching record");
cassandraDB.Attach(post);

// save the changes
Console.WriteLine("saving changes");
cassandraDB.SaveChanges();
}

public void read(byte[] key)
{
dynamic getPost = family.Get(key).FirstOrDefault();
Console.WriteLine("getPost");
byte[] value = getPost.value;
Console.WriteLine(value.Length);
}

}