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

InvalidOperationException when check Contains() == false

    • Type: Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Linq
    • None

      var selectedIds = new[] { ObjectId.GenerateNewId() };
      var result = postCollection
          .AsQueryable()
          .Where(p => selectedIds.Contains(p.Id) == false)
          .ToList();
      Message: System.InvalidOperationException : Contains(value(MongoDB.Bson.ObjectId[])) is not supported. 
      Stack Trace: 
      PredicateTranslator.GetFieldExpression(Expression expression) 
      PredicateTranslator.TranslateComparison(Expression variableExpression, ExpressionType operatorType, ConstantExpression constantExpression) 
      PredicateTranslator.TranslateComparison(BinaryExpression binaryExpression)
      PredicateTranslator.Translate(Expression node) 
      PredicateTranslator.Translate(Expression node, IBsonSerializerRegistry serializerRegistry) 
      QueryableTranslator.TranslateWhere(WhereExpression node) 
      QueryableTranslator.Translate(Expression node) 
      QueryableTranslator.TranslatePipeline(PipelineExpression node) 
      QueryableTranslator.Translate(Expression node) 
      QueryableTranslator.Translate(Expression node, IBsonSerializerRegistry serializerRegistry, ExpressionTranslationOptions translationOptions) 
      MongoQueryProviderImpl`1.Translate(Expression expression) 
      MongoQueryProviderImpl`1.Execute(Expression expression) 
      MongoQueryableImpl`2.GetEnumerator() List`1.ctor(IEnumerable`1 collection) 
      Enumerable.ToList[TSource](IEnumerable`1 source)
      

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            mj.ebrahimi72@gmail.com Mohamad Javad Ebrahimi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: