[CSHARP-493] LINQ - Allow Regex Usage inside $all Created: 13/Jun/12  Updated: 31/Mar/22

Status: Backlog
Project: C# Driver
Component/s: Linq
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Zaid Masud Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CSHARP-495 The "In" operator matches the whole e... Closed

 Description   

There appears to be no LINQ way to perform the following Mongo query:

db.Collection.find({field : {$all : [ /^a/, /^d/]}})

One possible suggestion to implement this is to create a ContainsAll overload that receives Regex parameters.



 Comments   
Comment by Zaid Masud [ 15/Jun/12 ]

This is a bit of a tangent to the specific issue reported here, but one thing we have seen with these custom extension methods is that unit testing becomes difficult. So for example, if our unit tests are using in-memory objects then ContainsAll won't work.

Here are two alternatives to ContainsAll using standard LINQ/.NET framework:

1) Support IsSubsetOf on two HashSets – this is the most natural C# interpretation of ContainsAll ... $all is really a Subset predicate.
2) Support !myValues.Except(collection.Array).Any() as a $all implementation

Of course neither would support regexes, so perhaps ContainsAll will still be needed for Regexes on $all.

Generated at Wed Feb 07 21:37:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.