MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Error with case insensitive search

Hi, all–

Just started using Realm- it’s amazing. I’m building an iOS app in Xamarin a having trouble making a .Where( x.contains(y)) query case-insensitive. The documentation states there’s an extension method which provides support for StringComparison.OrdinalIgnoreCase, but when I use it with a variable as the query source, it breaks. A string literal works. The error I get is here:

“The left-hand side of the Call operator must be a direct access to a persisted property in Realm.”

And this is the problematic line of code:

if (_opts.contains != null) query = query.Where(note => note.content.Contains(_opts.contains, StringComparison.OrdinalIgnoreCase));

Without the StringComparison, it works just fine:

if (_opts.contains != null) query = query.Where(note => note.content.Contains(_opts.contains));

When I try dropping in another variable, i.e.:

string queryContains = "blah";
if (_opts.contains != null) query = query.Where(note => note.content.Contains(queryContains, StringComparison.OrdinalIgnoreCase));

it fails as well.

As I mentioned, string literals work, i.e.:

if (_opts.contains != null) query = query.Where(note => note.content.Contains("blah", StringComparison.OrdinalIgnoreCase));

Any ideas what could be going on?

thanks!

: j