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

UWP: The view is not in sync with the database.

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None

      Goals

      Hello. I'm getting started with Realm platform to make an application in sync.

      The problem is that the data in my view does not become synced with db and I need to fetch it again.

      Expected Results

      I want to add a data to database and I want the data list to be in sync with DB.
      I bonded the ListView to an IRealmCollection.

      Actual Results

      When I add the data in the db using

      Unable to find source-code formatter for language: cs. 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
      var todo = new Todo()
                  {
                      Id = DateTime.UtcNow.Ticks.ToString(),
                      Subject = DateTime.Now.ToString(),
                      Detail = Details.Text,
                      Status = 2
                  };
                  RealmContext.Instance.Write(() =>
                  {
                      RealmContext.Instance.Add(todo);
                  });
      

      it saves successfully but the point is that UI does not update itself with newly added data; so I need to fetch the data again with RealmContext.Instance.All<Todo>().AsRealmCollection(); which is not what I want. When I subscribe to changes via

      TodayList.CollectionChanged += (s, e) =>
                  {
                      foreach (var item in TodayList)
                      {
                          Debug.WriteLine(item.Subject);
                      }
                  };
      

      the fun fact is that it is not triggered when I insert my first data into the db. it triggers second time.
      Even more fun is this, the VS debug output shows all items that I've added except the one that it didn't trigger this event !!! Please help.

      Code Sample

      You can take a look at the project that I'm working on at HERE

      In the core project there are everything related to the Database.
      Also TimelineViewModel.cs file is related to the issue.

      Views>Add>Task.xaml is for adding an item to DB.

      Version of Realm and Tooling

      • Realm Object Server Version: Last version. On the cloud
      • Client SDK Version: Windows 10 SDK 17134
      • Client OS & Version: 3.1.0

            Assignee:
            nikola.irinchev@mongodb.com Nikola Irinchev
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: