Closed nirinchev closed 2 years ago
I couldn't attach the zip so here's a link to the project that has it. https://github.com/JamieColclough/Frozen-object-has-incorrect-property-indices/tree/main/RealmSyncFreezeError I couldn't upload the packages but hopefully you can build the project with this
@JamieColclough thanks a lot for your project! We managed to reproduce the issue and we're currently investigating it.
@papafe Thanks! in the meantime, is there a workaround I can do so I can still use the frozen realm?
@JamieColclough we found the cause of the issue and we are working on a fix.
The workaround for now would be to have exactly the same schema locally as you have on MongoDB Realm (including the partition key). For example, ClinicAppointment
would look like this:
[MapTo("clinic_appointment")]
public class ClinicAppointment : RealmObject
{
[PrimaryKey]
[MapTo("_id")]
public int AppointmentId { get; set; }
[MapTo("_partition")]
[Required]
public string Partition { get; set; } //This is what you are missing right now
[MapTo("appointment_time")]
public DateTimeOffset AppointmentTime { get; set; }
[MapTo("clinic_schedule_id")]
public ClinicSchedule ClinicSchedule { get; set; }
[MapTo("clinician_id")]
public Clinician Clinician { get; set; }
[MapTo("is_uploading")]
public bool IsUploading { get; set; }
[MapTo("patient_record")]
public PatientRecord PatientRecord { get; set; }
[MapTo("patient_seen")]
public bool PatientSeen { get; set; }
[MapTo("status_id")]
public int StatusId { get; set; }
}
I don't know how exactly you are using frozen objects, as I suppose the project that you shared is probably a very simplified version of your use case, but I could also suggest not freezing the realm for now and just use the live objects.
This was fixed in 10.7.1.
Reported on the forums: https://www.mongodb.com/community/forums/t/realm-sync-net-freezing-an-object-on-a-synced-realm-messes-the-properties-up/126797
Looks like we're somehow using an incorrect object schema when looking up the properties, but it's not obvious what's causing it.