Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1865

Unsupported filter exception after upgrading from 2.3 to 2.4 driver

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.4.1
    • Affects Version/s: 2.3
    • Component/s: Linq
    • None
    • Environment:
      Windows 10 x64, Visual Studio 2015, asp.net core C# mongodb driver

      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.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            pwen090@gmail.com Paul Wen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: