Hello,
I would like to use Apache Cassandra database with help of cassandra-sharp to use it in C#. However, I have some problem with correctly referencing everything to ensure I can use Cassandra there.
I have found this article (
http://www.semoru.com/2012/07/27/how-to-connect-cassandra-and-net-framework-3-5/#comment-2766). I have converted the code from VB to C# and it looks like everything is correctly converted, except three lines.
using CassandraSharp.MadeSimple;
using Apache.Cassandra;
It cannot find MadeSimple and Apache. (Other using statements are OK after adding reference to cassandra library).
CqlResult res = cluster.ExecuteCql(queryString);
CqlResults and ExecuteCql cannot be found.
Could you give me some guidelines where it may result from?
The rest of code is OK.
Thanks in advance!
PS I have posted comment to that article but as last comment was from February, it may be simply forgotten by tutorial's creator or it may require some time to get any response.
The full code is like this:
using System.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using CassandraSharp;
using System.Text;
using CassandraSharp.Config;
using CassandraSharp.MadeSimple;
using Apache.Cassandra;
namespace CassandraSharpTest
{
class Program
{
public static void Main()
{
XmlConfigurator.Configure();
ICluster cluster = ClusterManager.GetCluster("TestCassandra");
string queryString = "select * from table";
CqlResult res = cluster.ExecuteCql(queryString);
ClusterManager.Shutdown();
}
public int getId(byte[] value)
{
byte[] buffer = new byte[value.Length];
value.CopyTo(buffer, 0);
Array.Reverse(buffer);
int result = BitConverter.ToInt32(buffer, 0);
return result;
}
public DateTime getDate(byte[] value)
{
byte[] buffer = new byte[value.Length];
value.CopyTo(buffer, 0);
Array.Reverse(buffer);
long ticks = BitConverter.ToInt64(buffer, 0);
System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
dateTime = dateTime.AddMilliseconds(ticks);
return dateTime;
}
public double getDouble(byte[] value)
{
byte[] buffer = new byte[value.Length];
value.CopyTo(buffer, 0);
Array.Reverse(buffer);
double result = BitConverter.ToDouble(buffer, 0);
return result;
}
}
}