reuzel/CqlSharp — pull request #23 by mikkelfish (2014-01-04 10:19:48+00:00)
Title: Add Fluent

Hello, I've created a fluent API for CqlSharp for a few reasons.

1) I really like the prepare functionality and object binding, but found the actual commands to be "magic strings" that were too complicated for error free behavior.

2) I wanted to marry the attribute tags defined on a class (column name, partition key, etc) with a command, so that there was as seamless binding as possible; similar to mongo db drivers, etc.

3) Cql has some quirks that I felt could be made clearer through a fluent syntax. For example, the primary key is the partition key(s) + clustering key(s) but the syntax for compound partition keys is not particularly obvious.

I'm not totally sure that this is ready to merge but thought it was good enough for you to take a look and give comments.

Also I couldn't get the test project to load (don't have a good enough Visual Studio) so made a separate test library using xunit.

Let me know if you have any thoughts! Thanks.

An example query that I've tested is:

```
var createTable = Define.CreateTable("test")
.HasPartitionKey("feature_id", typeof(Guid))
.FinishedClusteringKeys
.AddColumn("name", typeof(string))
.AddColumn("indexes_run", typeof(HashSet))
.FinishedDefiningColumns
.WithComment("This is a test")
.SetThrowOnError(false);
command = new CqlCommand(connection, createTable.BuildString);
command.ExecuteNonQuery();

var insert = Manipulate.Insert("test")
.With("feature_id")
.With("name")
.Finished;
command = new CqlCommand(connection, insert.BuildString, CqlConsistency.One);
command.Prepare();

var guid = Guid.NewGuid();
command.Parameters[0].Value = guid;
command.Parameters[1].Value = "What2";
command.ExecuteNonQuery();

var update = Manipulate.Update("test")
.AddSetItem("indexes_run")
.FinishedSet
.AddWhere("feature_id")
.FinishedWhere;

command = new CqlCommand(connection, update.BuildString, CqlConsistency.One);
command.Prepare();
command.Parameters["indexes_run"].Value = new HashSet{"test item"};
command.Parameters["feature_id"].Value = guid;
command.ExecuteNonQuery();
```

Alternatively you could have the following class definition and then generate the fluent automatically with

```
[CqlTable("test")]
class TestClass
{
[CqlColumn("feature_id", PartitionKeyIndex=1)]
public Guid id { get; set; }

[CqlColumn("name")]
public string Name { get; set; }

[CqlColumn("indexes_run")]
public HashSet IndexesRun { get; set; }
}

var create = Define.CreateTable();

var insert= Modify.Insert();

var update = Modify.Update(Utilities.Table)
.AddMapSet("indexes_run")
.FinishedSet
.WithStandardWhere(); //Makes sure that all primary keys are included in the where
```

using the existing prepare with object code.