craiggwilson / Simple.Data.MongoDB

MongoDB adapter for Simple.Data
35 stars 10 forks source link

DateTime property #7

Closed peterkeating closed 12 years ago

peterkeating commented 12 years ago

Hello,

I am having an issue when trying to cast an object that has a DateTime property.

In the tests, when adding a DateTime property to the User class, then running the tests 5 failed with the same exception, displayed below.

System.InvalidCastException : Invalid cast from 'Int64' to 'DateTime'.

I am not sure if this is specific to your Adapter or the Simple.Data library, but in the project that I was developing on when coming across the exception, I was using the InMemoryAdapter in my test suite and no exception is thrown.

Hope this helps :)

craiggwilson commented 12 years ago

Yep, it was definitely an adapter issue. The RawValue that comes back from mongo for dates is a long, not a DateTime. It's actually kinda odd and requires a massive if/else section to deserialize values. Anyhow, should be fixed and pushed to nuget.