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

Compare two fields with where throw exception "Unsupported filter"

    XMLWordPrintable

    Details

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

      Description

      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)
      
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: