The following C# code was working with Mongodb C# driver 2.3 until we upgraded to 2.4 and are now receiving an exception: Unsupported filter: (Convert({document}{QueryId}) == 44).
var collection = _database.GetCollection<AgentAnswer>("answers"); var scount = collection.AsQueryable() .Where(p => p.QueryId == id) .Where(p => p.LastUpdated > utc) .GroupBy(a => a.AgentId) .Distinct().Count();
This is example data within the collection:
{ "_id" : ObjectId("58480a1c51d9399d679e5c18"), "AgentId" : "825c47da-4498-4b99-8ba7-08d3e7e9e8cb", "Answers" : [ { "Computer" : "bm-DEV", "accounttype" : "512", "caption" : "bm-DEV\\bm", "domain" : "bm-DEV", "sid" : "S-1-5-21-652548636-764486669-3140530632-500", "fullname" : "", "name" : "bm" }, { "Computer" : "bm-DEV", "accounttype" : "512", "caption" : "bm-DEV\\DefaultAccount", "domain" : "bm-DEV", "sid" : "S-1-5-21-652548636-764486669-3140530632-503", "fullname" : "", "name" : "DefaultAccount" }, { "Computer" : "bm-DEV", "accounttype" : "512", "caption" : "bm-DEV\\Guest", "domain" : "bm-DEV", "sid" : "S-1-5-21-652548636-764486669-3140530632-501", "fullname" : "", "name" : "Guest" } ], "QueryId" : 44, "LastUpdated" : ISODate("2016-12-12T20:43:17.328Z") }
The full exception stack trace is as follows:
at MongoDB.Driver.Linq.Translators.PredicateTranslator.Translate(Expression node) at MongoDB.Driver.Linq.Translators.PredicateTranslator.Translate(Expression node, IBsonSerializerRegistry serializerRegistry) at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateWhere(WhereExpression node) at MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression node) at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateWhere(WhereExpression node) at MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression node) at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateGroupBy(GroupByExpression node) at MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression node) at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateGroupBy(GroupByExpression node) at MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression node) at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateGroupBy(GroupByExpression node) at MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression node) at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslatePipeline(PipelineExpression node) at MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression node) at MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression node, IBsonSerializerRegistry serializerRegistry, ExpressionTranslationOptions translationOptions) at MongoDB.Driver.Linq.MongoQueryProviderImpl`1.Execute(Expression expression) at MongoDB.Driver.Linq.MongoQueryProviderImpl`1.Execute[TResult](Expression expression) at WebServer.Services.MongoStore.<GetCountByQueryId>d__10.MoveNext() in C:\Users\User\Source\Repos\WebServer\Services\MongoStore.cs:line 143
Again this was working just fine in the 2.3 driver and only started causing an exception after upgrading to 2.4.
- duplicates
-
CSHARP-1867 Non-nullable members cannot be compared to nullable values
- Closed
- is related to
-
CSHARP-1867 Non-nullable members cannot be compared to nullable values
- Closed