Mongodb Realm doesn't support LINQ contain and any?

In Unity, I’m using Realm to sync with my MongoDB database. When I try to filter the results using the following code:

var dbMatchgames = realm.All<DBMatchgame>().Where(i => i.PlayerIDs.Contains(MyApp.CurrentUser.Id));
realm.Subscriptions.Add(dbMatchgames, new SubscriptionOptions() { Name = "MyMatchgame" });

I get an error saying that the Contains method is not supported. How can I avoid downloading all the documents in a collection?

You can use the string-based query syntax:

var myUserId = MyApp.CurrentUser.Id;

var dbMatchgames  = realm.All<DBMatchgame>().Filter("ANY PlayerIDs == $0", myUserId);
1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.