-
Type: Bug
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
I am using the MongoDB C# client to construct queries like "Name > 'Aardvark'". I can easily create a query that filters on strings case-sensitively, like this:
return Builders<T>.Filter.Gt("Name", "Aardvark");
I can't seem to find an option for comparing strings case insensitively. If I was writing the query directly in MongoDB, the query would look like this:
{ $expr: { $gte: [ {{{ $strcasecmp: [ "$Name", "}}Aardvark"] }, 0 ] } }
It seems like it should be possible to do this with the .Where() function, but that function only recognizes `obj => obj.Name.Equals("Aardvark", OrdinalIgnoreCase)`. It doesn't seem to permit any comparisons.
When I try the following, I get an error executing my query:
return Builders<T>.Filter.Where(x => String.Compare(x.Name, "Aardvark", OrdinalIgnoreCase);
Is there a better way to do this, or is this not implemented today?
- duplicates
-
CSHARP-4100 Review uses of StringComparison in StartsWith, Contains and EndsWith
- Closed