[CSHARP-423] .Where(item=>stringProperty.ToLower() == lowerCaseCheckValue) throws "Unsupported where clause:" exception Created: 30/Mar/12 Updated: 02/Apr/15 Resolved: 11/Apr/12 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.4 |
| Fix Version/s: | 1.4.1 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Mennan Kara | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Same exception gets thrown with .ToLowerInvariant(), ToUpper(), ToUpperInvariant(), Trim(), SubString(s,l). I'm guessing that the list goes on like this. |
| Comments |
| Comment by Robert Stam [ 11/Apr/12 ] | |||||||||||||||||||||||||||||||||||||||||
|
The following: ToLower can be combined with: Contains The following can be used stand alone: Equals (static and instance method) The following are not supported (but might be in the future): IsNullOrWhiteSpace (introduced in .NET Framework 4) | |||||||||||||||||||||||||||||||||||||||||
| Comment by Mennan Kara [ 31/Mar/12 ] | |||||||||||||||||||||||||||||||||||||||||
|
Very nice thinking about regular expressions. Thanks. | |||||||||||||||||||||||||||||||||||||||||
| Comment by Robert Stam [ 30/Mar/12 ] | |||||||||||||||||||||||||||||||||||||||||
|
Looks like lots of string methods could be supported in LINQ queries by translating the expressions to MongoDB queries using regular expressions. Here's a list of possible translations: d is the document
Combining multiple methods would be tricker. An example would be:
| |||||||||||||||||||||||||||||||||||||||||
| Comment by Robert Stam [ 30/Mar/12 ] | |||||||||||||||||||||||||||||||||||||||||
|
Not all LINQ queries can be turned into equivalent MongoDB queries, because C# allows you to write expressions that don't have any equivalent in the MongoDB query language. Unless I am missing something, none of the expressions you listed have an equivalent in the MongoDB query language. Some of them might be expressible using regular expressions though. I'll investigate that. | |||||||||||||||||||||||||||||||||||||||||
| Comment by Mennan Kara [ 30/Mar/12 ] | |||||||||||||||||||||||||||||||||||||||||
|
Also doesn't support string.Length
| |||||||||||||||||||||||||||||||||||||||||
| Comment by Mennan Kara [ 30/Mar/12 ] | |||||||||||||||||||||||||||||||||||||||||
|