datastax/csharp-driver — pull request #18 by teddymaef (2014-03-20 04:06:23+00:00)
Title: Add named parameters & prepared statement support to CqlCommand

Parameters & prepared statement support of CqlCommand is quite necessary to prevent Cql injection and for better query performance. This pullrequest implements the full featured named parameter support in CqlCommand class.

The only format of the named parameter supported is e.g.
insert into ef_common_data_cassandra_perf_test (ID, Int1, Str1, Date1) values (now(), :int1, :str1, :date1);

And as long as parameter values are added to the CqlCommand as below:
cmd.Parameters.Add(":str1", "str1");
cmd.Parameters.Add("int1", 1);
cmd.Parameters.Add("date1", DateTime.Now);

As common sense, when executing the command, a prepared statement instance is created & cached, and the values of the parameters will be bound to it in the order of the occurrence of parameter names in the cql. And it supports parameters with the same name occur multiple times in the cql.

I also added unit tests for related code and this feature has already been used in our company projects for a while which just works fine.