Best practice to handle a "template" realm and an editing Realm

Hello,

I’m using the latest 10.13.0 Realm SDK for .Net
The application is using WPF and .NET 6

I’ve been using Realm Sync for quite a while now, I’ve read the doc and discovered that it is possible to use multiple realm databases by using multiple partitions names. However I didn’t find any guides with good pratices on how to use this feature

What I’m trying to achieve is pretty simple :

The application would use 2 realms,
One which is a read only “template” synced realm (the user don’t have the write permission on this one, it can only read it)
and one which is the user partition in which he can do whatever modifications he needs to do (read and write permissions)

Here’s a quick exmple:

public async Task Init(Project project, string userId) {
    _templateRealmPartition = $"projectId={project.id}&template=true";
    _userRealmPartition = $"userId={userId}&projectId={project.id}";

   // Download everything from the template realm
   ...
}

And whenever the user is writting a modification to the template realm, it should write the modified item inside the user realm for exemple :

public void ChangeCarColor(Car car, string newColor) {
            // The car object is from the templateRealm
            using var realm = Realm.GetInstance(_userRealmPartition);
            realm.Write(() =>
            {
                car.color = newColor
                realm.add(car)
            });
}

Am I using the good approach or is there a better one ?

Thanks for your help :slight_smile: