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

Compare two fields with where throw exception "Unsupported filter"

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.9.2
    • Component/s: API, Command Operations
    • None

      I want find data where field1 (DateTime) < field2 (DateTime). This is my query:

       

      FilterDefinition<Measurement> filter = fb.And(
       fb.Eq(m => m.DataProvider, new ObjectId(dataProviderId)),
       fb.Where(m => m.RcvTime < m.ObsTime));

      В результате я получаю следующую ошибку

      Unhandled Exception: System.ArgumentException: Unsupported filter: ({document}{RcvTime} < {document}{ObsTime}).
         at MongoDB.Driver.Linq.Translators.PredicateTranslator.Translate(Expression node)
         at MongoDB.Driver.Linq.Translators.PredicateTranslator.Translate(Expression node, IBsonSerializerRegistry serializerRegistry)
         at MongoDB.Driver.AndFilterDefinition`1.Render(IBsonSerializer`1 documentSerializer, IBsonSerializerRegistry serializerRegistry)
         at MongoDB.Driver.MongoCollectionImpl`1.CreateFindOperation[TProjection](FilterDefinition`1 filter, FindOptions`2 options)
         at MongoDB.Driver.MongoCollectionImpl`1.FindAsync[TProjection](IClientSessionHandle session, FilterDefinition`1 filter, FindOptions`2 options, CancellationToken cancellationToken)
         at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSessionAsync[TResult](Func`2 funcAsync, CancellationToken cancellationToken)
         at Csdn.TimeCheck.Program.Main(String[] args) in /home/valera/RiderProjects/Csdn.TimeCheck/Csdn.TimeCheck/Program.cs:line 30
         at Csdn.TimeCheck.Program.<Main>(String[] args)
      
      

            Assignee:
            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            Reporter:
            boniface Vorobjev Valery
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: