[RavenDB] Bug with using Enum's?

32 views
Skip to first unread message

cosullivan

unread,
May 22, 2010, 1:41:50 AM5/22/10
to ravendb
Hi,

I have a class which uses a simple enum

enum Gender { Male, Female }

This is being serialized in the JSON document as the numerical value,
however, the JsonEnumConverter is expecting it to be read out as a
string and therefore I get the following exception;

Unhandled Exception: System.InvalidCastException: Unable to cast
object of type
'System.Int64' to type 'System.String'.
at Raven.Database.Json.JsonEnumConverter.ReadJson(JsonReader
reader, Type obj
ectType, Object existingValue, JsonSerializer serializer)

Is this a bug, or is there some other way to deal with Enums in Raven?

Regards,
Cain O'Sullivan

Matt

unread,
May 22, 2010, 4:37:58 AM5/22/10
to ravendb
I seen exactly the same thing, for now I just switched to using
strings.

Ayende Rahien

unread,
May 22, 2010, 4:55:04 AM5/22/10
to rav...@googlegroups.com
Bug

Ayende Rahien

unread,
May 22, 2010, 5:24:57 AM5/22/10
to rav...@googlegroups.com
Fixed

cosullivan

unread,
May 22, 2010, 8:29:34 AM5/22/10
to ravendb
Excellent.

Thanks for the prompt reply.

On May 22, 5:24 pm, Ayende Rahien <aye...@ayende.com> wrote:
> Fixed
>
>
>
> On Sat, May 22, 2010 at 11:55 AM, Ayende Rahien <aye...@ayende.com> wrote:
> > Bug
>
> > On Sat, May 22, 2010 at 8:41 AM, cosullivan <cain.osulli...@gmail.com>wrote:
>
> >> Hi,
>
> >> I have a class which uses a simple enum
>
> >> enum Gender { Male, Female }
>
> >> This is being serialized in the JSON document as the numerical value,
> >> however, the JsonEnumConverter is expecting it to be read out as a
> >> string and therefore I get the following exception;
>
> >> Unhandled Exception: System.InvalidCastException: Unable to cast
> >> object of type
> >> 'System.Int64' to type 'System.String'.
> >>   at Raven.Database.Json.JsonEnumConverter.ReadJson(JsonReader
> >> reader, Type obj
> >> ectType, Object existingValue, JsonSerializer serializer)
>
> >> Is this a bug, or is there some other way to deal with Enums in Raven?
>
> >> Regards,
> >> Cain O'Sullivan- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages