C.U. C.U. - 2 months ago 16
C# Question

ClusterKey Attribute in DataStax C# Driver

I have been trying to get a test object mapping working using the attributes in the Datastax C# driver for Cassandra.
There is a table in cassandra defined by

CREATE TABLE test.omfieldtest (
integer int,
bigint varint,
stringtext text,
universal uuid,
bool boolean,
singleprecision float,
variableprecision decimal,
PRIMARY KEY ((integer), bigint, stringtext, universal)

I then have a decorated C# class to map to that table

public class MappingTest
public Int32 integer;
[ClusteringKey(0, SortOrder.Ascending, Name = "bigint")]
public Int64 bigint;
[ClusteringKey(1, SortOrder.Ascending, Name = "stringtext")]
public string stringVal;
[ClusteringKey(2, SortOrder.Ascending, Name = "universal")]
public Guid universal;
public bool boolVal;
public Single singlePrecisionVal;
public decimal variablePrecisionVal;

Upon using
, an InvalidQueryException is thrown with the problem of an "Unknown identifier stringval".If I change the name of the property to match the column name, everything works fine, regardless of what the Name property of the
is set to.

So then what is the purpose or even the effect of specifying the Name property for the


It looks you've hit a driver bug in the Mapper/Linq components. I've created a ticket to track it: CSHARP-507

Luckily, there's a workaround: including the ColumnAttribute along with the clustering key, in your case would be:

public string stringVal;

I've also included a failing test in the repository: https://github.com/datastax/csharp-driver/commit/9917bfff4ef569525a6df845f35d31d817e79dc0