LINQ ToObject<> Method

May 21, 2013 at 7:24 PM
Edited May 21, 2013 at 7:27 PM
I have the following column family in my Cassandra keyspace (from using describe):
   id text PRIMARY KEY,
   flag int,
   anotherflag int,
   lastupdate timestamp
I am trying to use LINQ to obtain a list of all rows in this column family. My object is defined as:
public class MyObject
     public string id { get; set; }
     public int flag{ get; set; }
     public int anotherflag{ get; set; }
     public long lastupdate { get; set; }
And my LINQ query is:
var records = (from x in context.ColumnList
               where x.ColumnFamily == "state"
               select x.ToObject<MyObject>());
After running this, the records object is populated with MyObject objects, but all the fields are either null or 0.

When I change the LINQ query to just return x and not x.ToObject, I see that in x.Data all columns' name and value are in byte arrays. When I convert the column names using the ToUTF8 function I get the column name surrounded with extra characters. In addition, the id column is not being returned in the data but an empty column name is.

Any ideas on what I'm doing wrong and how to use LINQ to get a list of MyObject objects?

Thanks for any insight!