Description
Summary
After updating to the latest version of the mongodb driver (2.19), which switched to the LINQ3 queryable provider, an existing query is throwing with the exception:
MongoDB.Driver.Linq.ExpressionNotSupportedException: Expression not supported: x.Dict.get_Item("test"). at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToAggregationExpressionTranslators.MethodTranslators.GetItemMethodToAggregationExpressionTranslator.Translate(TranslationContext context, MethodCallExpression expression) |
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
MongoDBDriver 2.19.1, running against a local server version 6.0.5
How to Reproduce
Example console app:
using MongoDB.Driver;
|
using MongoDB.Driver.Linq;
|
|
|
var Query = (LinqProvider provider) =>
|
{
|
var connectionstring = "mongodb://docker:mongopw@localhost:49153"; |
var settings = MongoClientSettings.FromConnectionString(connectionstring);
|
settings.LinqProvider = provider;
|
var client = new MongoClient(settings); |
var db = client.GetDatabase("db1"); |
var collection = db.GetCollection<ExampleClass>("collection1"); |
return collection.AsQueryable().Select(x => x.Dict["test"]).First(); |
};
|
|
|
Console.WriteLine(Query(LinqProvider.V2)); // Works |
Console.WriteLine(Query(LinqProvider.V3)); // Throws exception |
|
|
class ExampleClass |
{
|
public IDictionary<string, int> Dict { get; set; } |
}
|
Additional Background
Tried to do some investigation, from what I can tell, GetItemMethodToAggregationExpressionTranslator.Translate calls TryGetIDictionaryGenericInterface but there is no check that the `type` parameter itself is an `IDictionary` like `TryGetIEnumerableGenericInterface` does.