-
Type: Bug
-
Resolution: Duplicate
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Summary
When upgrading to version 2.19 we noticed that our 'exists' filters were breaking and throwing an error message. We believe that this may be an issue with the way LINQ3 handles the filter.
Below is the error message it spits out at us when we try to use a string variable as a key using bracket notation. It should be noted that this was working when first written using MongoDB.Driver version 2.14.1 and still works if we revert the version.
MongoDB.Driver.Linq.ExpressionNotSupportedException : Expression must be a constant:
For our codebase we create a filter definition like this:
Builders<TempObj>.Filter.Exists(t => t.Sections[cultureCode])
Where we get passed a string called "cultureCode" that contains the key for the Sections object. We must pass the key name as a parameter since Sections is an object that can have either one or up to 20+ different keys that we do not know at compile time.
An example of the object being store within Mongo would be like:
{ Name: "Temp", Sections: { "en-US": {}, "en-CA": {}, ... } }, { Name: "Temp", Sections: { "en-US": {}, } },
How to Reproduce
Try to use a filter definition like this using bracket notation.
Builders<TempObj>.Filter.Exists(t => t.Sections[cultureCode])
Additional Background
I don't have much extra to put here, but if further details are needed I can try and provide them.
- duplicates
-
CSHARP-4562 SortBy failure for dictionary entry in LinqProvider.V3
- Closed
- is related to
-
CSHARP-4562 SortBy failure for dictionary entry in LinqProvider.V3
- Closed