How to map a C# enum to a Cassandra field using Datastax C# Driver? -


i save , retrieve poco object , cassandra using datastax c# driver (.net framework 4.6.1, datastax c# driver 3.0.8)

example:

public enum documentstate {     new = 0,     approved = 1,     rejected = 2 }  public class documentreadmodel {     public guid documentid { get; set; }     public documentstate state { get; set; } } 

what best way persist object in cassandra?

my approach not seem work.

for tried save int in cassandra:

create table if not exists documentreadmodel (         documentid uuid primary key,         state int); 

also used mapping configuration offered datastax driver following code:

mappingconfiguration.global.define(     new map<documentreadmodel>()             .tablename("documentreadmodel")             .partitionkey(o => o.merchantid)             .column(o => o.state, c =>     c.withname("state").withdbtype<int>())); 

but still exception:

cassandra.invalidtypeexception:  unknown cassandra target type clr type valueobjects.documentstate 

should use type int in cassandra? configure driver differently?


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -