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

Did you ever figure this out? I am having the same issue. Another thing I can do to make it work is replace the compared string variable with a string literal and it works.

@Sevren_Brewer can you file an issue at GitHub - realm/realm-dotnet: Realm is a mobile database: a replacement for SQLite & ORMs and ideally provide some code samples and the team will be happy to dive deeper.