realm / realm-dotnet

Realm is a mobile database: a replacement for SQLite & ORMs
https://realm.io
Apache License 2.0
1.25k stars 165 forks source link

Create tests for Many-To-Many relationships #2504

Open papafe opened 3 years ago

papafe commented 3 years ago

We need to have tests for many-to-many relationships like the following one:

    public class User : RealmObject
    {
        [PrimaryKey]
        public string Id { get; set; } = Guid.NewGuid().ToString();

        public string Name { get; set; }

        public IList<ShoppingList> ShoppingLists { get; }
    }

    public class ShoppingList : RealmObject
    {
        [PrimaryKey]
        public string Id { get; set; } = Guid.NewGuid().ToString();

        public string Name { get; set; }

        [Backlink(nameof(User.ShoppingLists))]
        public IQueryable<User> Owners { get; }
    }

We also need to check that the documentation has examples on how to create backlinks for those

nirinchev commented 3 years ago

We should also test that backlinks work with dictionaries and sets.

carbonete commented 3 years ago

Hi, https://docs.mongodb.com/realm/sdk/dotnet/fundamentals/relationships/ Not contain a clear many to many topic. Example at one-to-many relationship not use relation to explain.

How we proceed when found doc problem, I try "Give Feedback" at documentation site but i never receive return or problem is corrected.

Thanks

carbonete commented 3 years ago

Hi, many to many is explained at https://docs.mongodb.com/realm/sdk/dotnet/examples/define-a-realm-object-model/#std-label-dotnet-index-property-example And in many to many topic box example is not many to many.

papafe commented 3 years ago

Hi @carbonete, you're right that the current documentation is not very clear about many-to-many relationships. We will try to make it more clear, thanks for your feedback.

DominicFrei commented 3 years ago

Hi @carbonete !

I have talked to our docs team. We'll work on figuring out why you did get an answer to your feedback.

In the meantime I've also talked to them about the examples. They are indeed misleading as of today. The reason is that this was the recommended way before we introduces embedded objects.

After they have been introduced relationships can be enforced more clearly:

Our docs team is aware of that fact now and will work on updating the documentation.