Uploaded image for project: 'Realm .NET SDK'
  1. Realm .NET SDK
  2. RNET-1171

List of EmbeddedObject no longer being returned with parent object.

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None

      What happened?

      I have Journal and JournalEntry classes per the definitions below. During startup, some sample data is created including 3 Journal objects each with either two or three JournalEntry objects attached. Subsequently, I use the following query to retrieve the list of Journals.

      `
      var journalList = new ObservableCollection<Journal>(_realm.All<Journal>().OrderBy(x => x.Date).ToList());
      `

      All three of the Journal objects retrieved have an empty Entries list (i.e. list count is zero).

      I'm not sure which package upgrade caused this to stop working.

      Repro steps

      Interestingly though, if I migrate all objects to partial classes and use interfaces (i.e IRealmObject) it starts working again. However, this appears to bring heaps of pain with compiler nullability warnings left, right, and centre that I cannot seem to resolve.

      Version

      Realm 12.3.

      What Atlas Services are you using?

      Local Database only

      What type of application is this?

      Other

      Client OS and version

      macOS 14.5; NET MAUI 8; C# 12

      Code snippets

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      public class Journal : RealmObject
      {
          [PrimaryKey]
          [MapTo("_id")]
          public string Id { get; set; } = Guid.NewGuid().ToString();
      
          [MapTo("date")]
          public DateTimeOffset Date { get; set; }
      
          [MapTo("counterparty")]
          public Counterparty Counterparty { get; set; } = new ();
      
          [MapTo("memo")]
          public Memo? Memo { get; set; }
      
          [MapTo("reporting_group")]
          public ReportingGroup? ReportingGroup { get; set; }
      
          [MapTo("amount")]
          public decimal Amount { get; set; }
      
          [MapTo("entries")]
          public IList<JournalEntry> Entries { get; } = [];
      }
      
      
      public class JournalEntry : EmbeddedObject
      {
          [MapTo("_id")]
          public string Id { get; set; } = Guid.NewGuid().ToString();
      
          [MapTo("account")]
          public Account Account { get; set; } = new();
      
          [MapTo("currency")]
          public Currency Currency { get; set; } = new();
      
          [MapTo("amount")]
          public decimal Amount { get; set; }
      
          [MapTo("is_credit")]
          public bool IsCredit { get; set; }
      }
      

      Stacktrace of the exception/crash you're getting

      No response

      Relevant log output

      No response

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: