Are Enums not supported in UDT's?
If I've got a type like this:
If I try using a `CqlQuery` that gets passed an expression where the enum property is matched to some value in that enum, I get the following error:
Given this issue: https://slack-redir.net/link?url=https%3A%2F%2Fdatastax-oss.atlassian.net%2Fbrowse%2FCSHARP-326%3Fjql%3Dproject%2520%253D%2520CSHARP%2520AND%2520text%2520~%2520enum, I would have expected enum's are supported?
am I missing something?
This might need to be on a second Jira issue, but I'll start with noting this:
Looks like the Mapper isn't actually being used since MapperFactory.GetExpressionToGetValueFromPoco sees column.MemberInfoType == column.ColumnType and thinks no conversion is necessary.
Hmm I coded a simple example with a custom type converter today for another topic but it might be useful here: https://gist.github.com/joao-r-reis/da1ca4f982f3351444699316ec975ba9
This example shows how to use a json based type converter but it should be the same as for an enum. The column.MemberInfoType == column.ColumnType condition should return false because one is an enum and another is int right?
> The column.MemberInfoType == column.ColumnType condition should return false because one is an enum and another is int right?
It will only be int if I put Type = typeof(int) on the Column attribute. When I do that it seems I don't actually need the custom type mapper though.
Yes, if you do that then it will attempt to do a cast and the cast will work, so the custom type converter is not needed. Adding that Type=typeof(int) part is the recommended way to work with enums, at least until this ticket is addressed I suppose.
The TypeConverter acts with the data that is returned by the Serializer, so maybe you are looking for type serializers instead? BuilderWithTypeSerializers(TypeSerializerDefinitions definitions) I haven't tried it yet but I believe you don't need to specify the DbType if you provide a type serializer definition for the enum.