Sooner or later, you’ll come to the point, that you don’t only want to get objects by Id or the whole set of objects of a specific type in Realm. The easiest, but probably most unsophisticated way to do it, would be just use a function on a Linq-Where statement. That’s easy and has reasonable performance, no need to iterate and implement it yourself. But it actually is a big waste of resources, because depending upon the function, every single element needs to be evaluated.
But there is a better way to do so, eventhough it’s support in Realm is very confined. You can use Linq-Expressions. In the next table you find a plan, on what is supported or not:
Contains, StartsWith, EndsWith
|class.Text.StartsWith(“T”)||✓||as StringComparison you can use Ordinal or OrdinalIgnoreCase|
|advanced calculation||class.Number*20>100||╳||no left-side operations are supported, but right-side operations|
|Same-Object Comparison||class.Number>class.Number2||╳||only comparison with constant values are supported|
That’s really not a lot. Actually it ends up with numeric type comparisons (==,<,>..) and some string-Comparer (==,Contains, StartsWith, EndsWith). I really hope Mongo Inc. will spend some more time on implementing more Linq-Expression features in Realm.
|List-Functions||ANY SubClassArray.Number>10||ANY or SOME works only with RealmObject-Arrays, not with atomic type arrays|
Summarizing my investigation and research on this, I can say: There’s space for improvement. I am very keen on finding out, whether MongoRealm will have a more sufficient way to query data.