Add reference to document on a different partition to IList

Hello everyone,

I’m fairly new to Realm and I’ve been stuck on one issue for quite some time now. For reference, I’m using Xamarin Forms (C# + .Net) and Realm Sync.

I have 3 collections in Atlas (User, Match and Player). In the User collection, I want to reference Matches and Players which are on a different (shared) partition (i.e. “allmatches=allmatches” and “allplayers=allplayers”). However, when I try to add a reference to an existing match or player to a user’s match/player lists so that it gets synced locally, I get a BadChangeError complaining that the document is on a different partition. Based on a lot of reading and my understanding of partitions, I understand why I get the error. My question is, what’s the correct approach for doing something like this?


Here’s the error:

UPDATE instruction had incorrect partition value for key “_partition” { expectedPartition: user=615904707e2079114573f89a, foundPartition: players=players }

My simplified schemas for the 3 Atlas collections are below with the _id and _partition fields & attributes removed for clarity.

   public class User : RealmObject
       public IList<Player> Friends { get; }
       public IList<Match> Matches { get; }

   // The collections below should be accessible to all users.  
   // That is, if they search for a match or player, they should be able to see that data AND have it added to their synced realm so it's available if they lose a connection (i.e. they need to keep playing their match which is saved at the end and synced once they are back online).

   public class Match : RealmObject	
      public string Title { get; set; }
      public IList<Game> Games { get; }	// Game is an embedded issues with that.

   public class Player : RealmObject // should also be public info which should be accessible to all users]
      public string Username { get; set; }
      public byte[] ThumbnailImage { get; set; }