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

Regression 2.3 driver- Nullible List Contains operator

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.4.3
    • Affects Version/s: 2.3
    • Component/s: Linq
    • None
    • Environment:
      Windows

      I have a fairly simple method shown below that worked with the 2.2.x driver but now throws an error

              public void RemoveEventsIfExists(IEnumerable<long> persistentIds)
              {
                  var pIds = persistentIds.Select(x => x as long?);
                  someIMongoCollection.DeleteMany(x => pIds.Contains(x.SomeNullableLongProperty));
              }
      
      

      Exception Message:

      Unable to cast object of type 'MongoDB.Bson.Serialization.Serializers.ImpliedImplementationInterfaceSerializer`2[System.Collections.Generic.IEnumerable`1[System.Nullable`1[System.Int64]],System.Collections.Generic.List`1[System.Nullable`1[System.Int64]]]' to type 'MongoDB.Bson.Serialization.IBsonSerializer`1[System.Int64]'.

      Stack Trace:

      at MongoDB.Bson.Serialization.Serializers.NullableSerializer`1.MongoDB.Bson.Serialization.IChildSerializerConfigurable.WithChildSerializer(IBsonSerializer childSerializer)
      at MongoDB.Driver.Linq.SerializerHelper.RecursiveConfigureChildSerializer(IChildSerializerConfigurable configurable, IBsonSerializer childSerializer)
      at MongoDB.Driver.Linq.Processors.PipelineBindingContext.GetSerializer(Type type, Expression node)
      at MongoDB.Driver.Linq.Processors.EmbeddedPipeline.EmbeddedPipelineBinder.BindNonMethodCall(Expression node)
      at MongoDB.Driver.Linq.Processors.PipelineBinderBase`1.Bind(Expression node)
      at MongoDB.Driver.Linq.Processors.PipelineBinderBase`1.BindPipeline(Expression node)
      at MongoDB.Driver.Linq.Processors.PipelineBinderBase`1.BindMethodCall(MethodCallExpression node)
      at MongoDB.Driver.Linq.Processors.PipelineBinderBase`1.Bind(Expression node)
      at MongoDB.Driver.Linq.Processors.EmbeddedPipeline.EmbeddedPipelineBinder.Bind(Expression node, IBindingContext parent)
      at MongoDB.Driver.Linq.Processors.SerializationBinder.BindEmbeddedPipeline(MethodCallExpression node)
      at MongoDB.Driver.Linq.Processors.SerializationBinder.VisitMethodCall(MethodCallExpression node)
      at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
      at MongoDB.Driver.Linq.Processors.SerializationBinder.Visit(Expression node)
      at MongoDB.Driver.Linq.Translators.PredicateTranslator.Translate[TDocument](Expression`1 predicate, IBsonSerializer`1 parameterSerializer, IBsonSerializerRegistry serializerRegistry)
      at MongoDB.Driver.ExpressionFilterDefinition`1.Render(IBsonSerializer`1 documentSerializer, IBsonSerializerRegistry serializerRegistry)
      at MongoDB.Driver.MongoCollectionImpl`1.ConvertWriteModelToWriteRequest(WriteModel`1 model, Int32 index)
      at System.Linq.Enumerable.<SelectIterator>d__5`2.MoveNext()
      at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.BatchHelper.<FindOrderedRuns>d__8.MoveNext()
      at MongoDB.Driver.Core.Misc.ReadAheadEnumerable`1.ReadAheadEnumerator.MoveNext()
      at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.BatchHelper.<GetBatches>d__6.MoveNext()
      at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.Execute(IWriteBinding binding, CancellationToken cancellationToken)
      at MongoDB.Driver.OperationExecutor.ExecuteWriteOperation[TResult](IWriteBinding binding, IWriteOperation`1 operation, CancellationToken cancellationToken)
      at MongoDB.Driver.MongoCollectionImpl`1.ExecuteWriteOperation[TResult](IWriteOperation`1 operation, CancellationToken cancellationToken)
      at MongoDB.Driver.MongoCollectionImpl`1.BulkWrite(IEnumerable`1 requests, BulkWriteOptions options, CancellationToken cancellationToken)
      at MongoDB.Driver.MongoCollectionBase`1.DeleteMany(FilterDefinition`1 filter, CancellationToken cancellationToken)
      at MongoDB.Driver.IMongoCollectionExtensions.DeleteMany[TDocument](IMongoCollection`1 collection, Expression`1 filter, CancellationToken cancellationToken)
      at MyLibrary.RemoveEventsIfExists(IEnumerable`1 persistentIds) in C:\dev\MyRepo.cs:line 1266

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            bret@cityspark.com Bret Ferrier
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: