Migration of iOS realm to Xamarin - DateTime issue


#1

Hi,

I’m currently porting my iOS app to Xamarin. As I would like users to continue using their existing realm database, once the app will be updated to the Xamarin version, the update should be compatible.
I’ve noticed that Realm uses DateTimeOffset instead of DateTime in Xamarin. Unfortunately the dates stored as DateTime in the realm appear as “null” values or defaults to Jan. 1. 1970, 01:00:00.
I had a look at the real with the Realm Browser App on the Mac. After loading the realm into the Xamarin version of the app, all dates were resetted to Jan. 1. 1970, 01:00:00. The realm is being modified automatically, so even without any interaction by the user, which looks strange to me.
Is there a way to avoid this behavior?
I did’t find anything usable for this purpose within the migration. I let the migration walk through a set of data, but the dates were already defaulted, this seems to go deeper into the library, right?

Thank you in advance for your advise
Arno


#2

Found the answer by myself…
The reason was a missing optional “?” on the corresponding property, as it was optional on the Swift version of the app.
I found the answer within the generated model definitions in the Realm Browser App. Should have used it, instead of porting manually from Swift to C#. New lesson learned!

Cheers
Arno