Contains in Asp Net Core don't work with StringComparison


#1

this call works in Xamarin .Net, but don’t work in Asp Net Core .Net:

MyRealm.All()
.Where(u=>u.Name.Contains(txt,StringComparison.OrdinalIgnoreCase))
.OrderBy(u => u.Name);

Exception is: NotSupportedException: The method ‘Contains’ is not supported

Can anyone help me?

Thanks
Luigi


#2

Sorry for the delay - the issue is caused by the fact .NET Core 2.0+ ships with its own overload for Contains(string, StringComparison) that gets picked over our extension method. We’ll fix it with the next version of the .NET SDK, but in the meantime, you can explicitly use the extension method:

MyRealm.All<Foo>()
       .Where(f => StringExtensions.Contains(f.Name, "something", StringComparison.OrdinalIgnoreCase));

#3

Perfect!

Thanks
Luigi