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

Linq3Implementation: unknown operator: $dateTrunc

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: 2.23.1
    • Component/s: API
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Summary

      When you want to do specific date comparisons, the query fails with the following error:

      // MongoDB.Driver.MongoCommandException: Command aggregate failed: unknown operator: $dateTrunc.
        at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1[TCommandResult].ProcessResponse (MongoDB.Driver.Core.Connections.ConnectionId connectionId, MongoDB.Driver.Core.WireProtocol.Messages.CommandMessage responseMessage) [0x001e7] in <cd36eac244264074bbff0d6b85d1b81a>:0 
        at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1[TCommandResult].ExecuteAsync (MongoDB.Driver.Core.Connections.IConnection connection, System.Threading.CancellationToken cancellationToken) [0x00310] in <cd36eac244264074bbff0d6b85d1b81a>:0 
        at MongoDB.Driver.Core.Servers.Server+ServerChannel.ExecuteProtocolAsync[TResult] (MongoDB.Driver.Core.WireProtocol.IWireProtocol`1[TResult] protocol, MongoDB.Driver.Core.Bindings.ICoreSession session, System.Threading.CancellationToken cancellationToken) [0x000ad] in <cd36eac244264074bbff0d6b85d1b81a>:0 
        at MongoDB.Driver.Core.Operations.RetryableReadOperationExecutor.ExecuteAsync[TResult] (MongoDB.Driver.Core.Operations.IRetryableReadOperation`1[TResult] operation, MongoDB.Driver.Core.Operations.RetryableReadContext context, System.Threading.CancellationToken cancellationToken) [0x0012d] in <cd36eac244264074bbff0d6b85d1b81a>:0 
        at MongoDB.Driver.Core.Operations.ReadCommandOperation`1[TCommandResult].ExecuteAsync (MongoDB.Driver.Core.Operations.RetryableReadContext context, System.Threading.CancellationToken cancellationToken) [0x00098] in <cd36eac244264074bbff0d6b85d1b81a>:0 
        at MongoDB.Driver.Core.Operations.AggregateOperation`1[TResult].ExecuteAsync (MongoDB.Driver.Core.Operations.RetryableReadContext context, System.Threading.CancellationToken cancellationToken) [0x000af] in <cd36eac244264074bbff0d6b85d1b81a>:0 
        at MongoDB.Driver.Core.Operations.AggregateOperation`1[TResult].ExecuteAsync (MongoDB.Driver.Core.Bindings.IReadBinding binding, System.Threading.CancellationToken cancellationToken) [0x0012d] in <cd36eac244264074bbff0d6b85d1b81a>:0 
        at MongoDB.Driver.OperationExecutor.ExecuteReadOperationAsync[TResult] (MongoDB.Driver.Core.Bindings.IReadBinding binding, MongoDB.Driver.Core.Operations.IReadOperation`1[TResult] operation, System.Threading.CancellationToken cancellationToken) [0x00075] in <1f4ccf81a3794552bec7798e120d9a2b>:0 
        at MongoDB.Driver.MongoCollectionImpl`1[TDocument].ExecuteReadOperationAsync[TResult] (MongoDB.Driver.IClientSessionHandle session, MongoDB.Driver.Core.Operations.IReadOperation`1[TResult] operation, MongoDB.Driver.ReadPreference readPreference, System.Threading.CancellationToken cancellationToken) [0x0009f] in <1f4ccf81a3794552bec7798e120d9a2b>:0 
        at MongoDB.Driver.MongoCollectionImpl`1[TDocument].AggregateAsync[TResult] (MongoDB.Driver.IClientSessionHandle session, MongoDB.Driver.PipelineDefinition`2[TInput,TOutput] pipeline, MongoDB.Driver.AggregateOptions options, System.Threading.CancellationToken cancellationToken) [0x002e3] in <1f4ccf81a3794552bec7798e120d9a2b>:0 
        at MongoDB.Driver.MongoCollectionImpl`1[TDocument].UsingImplicitSessionAsync[TResult] (System.Func`2[T,TResult] funcAsync, System.Threading.CancellationToken cancellationToken) [0x000fe] in <1f4ccf81a3794552bec7798e120d9a2b>:0 
        at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToExecutableQueryTranslators.ExecutableQuery`3[TDocument,TOutput,TResult].ExecuteAsync (MongoDB.Driver.IClientSessionHandle session, System.Threading.CancellationToken cancellationToken) [0x001d7] in <1f4ccf81a3794552bec7798e120d9a2b>:0  

      How to Reproduce

                  var interactions = await (await EquipmentInteractionsCollection.AsQueryable()
                      .Where(b => b.MemberId == memberId &&
                                  (b != null && b.InteractionDate != null && b.InteractionDate.Value.Date == beginDate.Date)).ToCursorAsync()).ToListAsync(); 

      Additional Background

      Please provide any additional background information that may be helpful in diagnosing the bug.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            sasan.pasha@gmail.com Sasan Pasha
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: