Dot-net 10.0.0-beta.5 DateTimeOffsets returned zeroed

Realm dot-net Upgraded (through Nuget) from 10.0.0-beta.2 to 10.0.0-beta.5
Clean and rebuild.

My RealmObject ‘Accommodation’ has a date field:
public DateTimeOffset Date { get; set; }

In beta.2 the following query always worked:
var result2 = _Realm.All(Accommodation) ();
(The editor does not accept greaterThan or LessThan chars)

In beta.5 it fails.
Every ‘Accommodation’ object returned has ‘Date’ zeroed: {01/01/0001 00:02:41 +00:00}

Switching back to beta.2 everything works again.

Realm Studio view of the realm file shows dates in Accommodation classes are correct,
(which they have to be for Beta.2 to work again).

A different class returns dates correctly (named ‘ArrivalDate’)
Could it be internal confusion due to the date simply being named ‘Date’ in the latest beta?
public DateTimeOffset Date { get; set; }

Any ideas?

Interesting, we do have tests for that but it’s possible you’re hitting a corner case we didn’t handle correctly. What you can try is to rename the property to date and remove the MapTo attribute. If that fixes the issue, it will indeed point to a bug with mapped properties. If it doesn’t, then we would probably need a repro case - can you by any chance share your project or reproduce the issue in a separate one?

I’ll try and reproduce it in another project which I can clear.
This project is a monster and has ‘live’ personal data on test, otherwise I’d be happy to clear the Realm.
Unfortunately the class I mentioned is used in numerous queries as well as c# code.

I’ll see what I can do right now.

1 Like

I have another class with
public DateTimeOffset Date { get; set; }
and a query returns an entry withe the date intact!
The only difference is Accommodations number 4700, the other class has only one item.

btw I tried another realm theogh GetDefaultInstance() and it still failed on the dates.

Very peculiar! It could also be related to the schema of the Accommodation class versus your other models - perhaps a particular order of the properties is causing incorrect values to be returned.

I’ll have a look at both areas.
They are all in same order on Schema and Class.

Baffling one this, especially as beta.2 works.
However, in the case of the second class I tried, I created several objects on realm just now.
The accommodations were created a week ago.
I can’t imagine there’s a bson date incompatibility between the betas.

I’m trying the Date to date mod on Accommodation…
Unfortunately removing the MapTo and renaming Date to date still fails.

OK interesting development.

I accessed one Accommodation object, updated the ‘Date’ with the correct datetime.

The query now returns a count of 1.

It appears beta.5 doesn’t like old dates !

That is indeed peculiar - I’ll ask the Core database folks and see if there have been any file format changes from beta.2 and get back to you.

Firstly, I checked out another PC running the app, untouched for days, and it works OK.

So, on this problem version…
I deleted the local realm file, installed beta.2, started the app and it works fine.
So, I deleted the local realm file, installed beta.5, started the app, and it fails with zeroed dateTimeOffsets.

I can continue working with good ol’ beta.2.

Talked with the Core folks and this is not something expected or previously reported. Let me try to summarize your observations:

  1. Upgrading an app from beta.2 to beta.5 results in DateTimeOffset properties for only one model being returned as zeroes.
  2. Downgrading to beta.2 results in correct dates being read.
  3. Modifying a property with beta.5 fixes the issue for this particular property.
  4. Realm Studio shows the correct data.

This is however inconsistent with your latest observation that deleting the Realm file and creating it from scratch with beta.5 still exhibits the problem, so there may be something else at play here.

It does seem like a bug though and to be able to proceed with investigating it, it will greatly help if:

  1. You can share a Realm file that exhibits the problem - i.e. reading it with beta.2 returns correct date properties, but reading it with beta.5 returns zeroes.
  2. If ^ is not possible, then an empty Realm file that has been opened with your app, just so that we can inspect the schema. The fact that only certain models exhibit the problem behavior points to a schema-related corner case.

btw Earlier, after changing dates in code using beta.5, reverting to beta.2 failed. Phew!
I can send you the current beta.2 realm file. I can send the class file and corresponding schema.
To which Email address should I send the data?
I can also send the Appid and Web Url from the dashboard if necessary.

Oh, I didn’t realize that was a synced Realm! That’s another data point, although not one that explains what’s going on :sweat_smile:

Can you send them over to and I’ll try to get a local repro.


Now working with fix in beta.6
Thanks .

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.