[CSHARP-1906] Case insensitive search using $in clause in Linq expressions Created: 01/Feb/17 Updated: 07/Jul/22 Resolved: 07/Jul/22 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Linq |
| Affects Version/s: | 2.3 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Mikhail Belov | Assignee: | Robert Stam |
| Resolution: | Duplicate | Votes: | 2 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Epic Link: | CSHARP-3615 | ||||||||
| Description |
|
Hi guys, It would be very useful to support case insensitive search using $in clause in Linq expressions. For example it might be done in this way:
Right now it's only possible to specify general values in the array and is not possible to specify regex values for case insensitive search. General equal clause suports it via ToLower() etc methods, but the driver throw an exception if there is a call of .ToLower() method inside the array.Contains() method in .Where() expression. Thanks, |
| Comments |
| Comment by James Kovacs [ 07/Jul/22 ] | ||||
|
This issue has been fixed in the new LINQ provider (known as LINQ3), which was introduced in the 2.14 release. Configure your MongoClientSettings to use LinqProvider.V3 if you want to use this functionality. To configure a client to use the LINQ3 provider use code like the following
| ||||
| Comment by Githook User [ 07/Jul/22 ] | ||||
|
Author: {'name': 'Robert Stam', 'email': 'robert@robertstam.org', 'username': 'rstam'}Message: | ||||
| Comment by Lucas Picchi [ 08/Sep/21 ] | ||||
|
Hi! Thanks for taking the time to explain the situation! | ||||
| Comment by James Kovacs [ 07/Sep/21 ] | ||||
|
Hi, Lucas, Thank you for reaching out to MongoDB. We apologize for allowing this issue and pull request to languish in our backlog for so long. We are currently working on a new LINQ provider, which is nearing completion and includes a fix for this issue. We plan to release the new LINQ provider as an opt-in option in the next release of the driver. We will update this issue with additional details once the new provider is available. In the meantime, a more performant solution to this problem - which will work with current and future drivers - is to define an case-insensitive index on the field and query using that collation. When defining your aggregation in C#, you would need to opt into the case-insensitive collation for that field. You can find an example of using a collation in our documentation. Sincerely, | ||||
| Comment by Lucas Picchi [ 06/Sep/21 ] | ||||
|
In 2021 this is still a problem, what is need to be done to get this merged? A lot of people in forums is asking about this feature. I would be glad to help fixing any code or conflict. | ||||
| Comment by Donald Urquhart [ 18/Aug/20 ] | ||||
|
There was a pull request for this 3 years ago? Really need this feature. | ||||
| Comment by Mikhail Belov [ 01/Feb/17 ] | ||||
|
I've sent pull request with this improvement: |