datastax/csharp-driver — pull request #44 by medvekoma (2014-09-26 13:27:29+00:00)
Title: Select to Tuple<> or other type with non-default constructor

When using LinqToCql, select into anonymous types works fine. But sometimes we need to select into a temporary class (for example we want to return it from a method, etc). In such situations the generic type Tuple is very useful:

table
.Where(condition)
.Select(entity => new Tuple(entity.IntField, entity.StringField)
.Execute();

This doesn't work for two reasons:
1. CqlExpressionVisitor.VisitNew(): node.Members is null for Tuples, the parameter information is stored in node.Arguments.
1. CqlQueryTools.GetRowFromCqlRow() requires that the type has a default constructor. The applied change accepts a non-default constructor if that is the only constructor, and its parameters match the parameters of the CQL query.

This pull request solves both problems. I created a number of unit tests to verify that select works for other entity types too.