fluentcassandra/fluentcassandra — pull request #139 by Aaronontheweb (2013-11-01 01:50:16+00:00)
Title: CQL3 collection support

Resolves issue #96 and provides a concrete implementation of CQL3 collections (`SetType`,`ListType`, and `MapType`.)

Bumped FluentCassandra assembly version number to **1.2.3**

Here's an example of what this functionality looks like, directly from one of the CQL3 unit tests (using a `MapType`):

````
//arrange
var mapItem1 = new KeyValuePair(11310101L, new Guid("88F1F2FE-B13B-4241-B17E-B8FAB8AC588B"));
var mapItem2 = new KeyValuePair(-452117101L, new Guid("1AFBBD02-C4D5-46BD-B5F5-D0DCA91BC049"));
var items = new[] {mapItem1, mapItem2};

var insertQuery = @"INSERT INTO Cql3Map (Id, TagMap) VALUES(1, {" + mapItem1.Key + ":" + mapItem1.Value + ", " + mapItem2.Key + ":" + mapItem2.Value + "});";

//act
_db.ExecuteNonQuery(insertQuery);
var results = _db.ExecuteQuery("SELECT * FROM Cql3Map").ToList();

//assert
var row = (FluentCqlRow)results.First();
var tagmap = row.GetColumn("tagmap").ColumnValue.GetValue>();

Assert.Equal(mapItem1.Value, tagmap[mapItem1.Key]);
Assert.Equal(mapItem2.Value, tagmap[mapItem2.Key]);
````

### Features

* Converts CQL columns directly into `IList<>` and `IDictionary<>` without having to expose any Cassandra types. As long as the Set / List / Map's Cassandra types can be safely casted to the List / Dictionary type, everything will go through automagically.

* Extensible - can be used to support future CQL datatypes automatically without needing to update the `SetType`, `ListType`, or `MapType`. This will be useful when Cassandra gets the ability to support nested collections, for instance.

### Notes:

1. I broke convention with the CompositeType implementations, which were able to keep generic parameters out of the base class definition. I made this choice considering that Set, List, and Map contain a fixed number of invariable types.

2. The MapType object doesn't support some of the smooth implicit conversions to CassandraObject[] and others, primarily because there isn't a `KeyValuePair<,>` : `CassandraObject` implementation. If this causes issues for anybody we'll consider adding support for one, but I don't anticipate any issues with it right away.

3. I have not tested LinqToCql3 support yet for writing CQL3 collections out to Cassandra. This will need to be done sooner or later.

----
Going to wait a couple of days for feedback before I merge the pull request, since this is a relatively large change.