ArgumentNullException when building Pull command on array element without nested property

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.9.1
    • Component/s: LINQ
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Following code fails with ArgumentNullException:

      var participants = new[]

      { 123, 456, 789 }

      ;
      var builder = new MongoDB.Driver.Builders.UpdateBuilder<Domain.Match>();
      var mongoQuery = builder.Pull(m => m.ParticipantNumbers, query => query.Where(p => participants.Contains(p))); //This line fails with the exception

      Stack trace:
      System.ArgumentNullException: Value cannot be null.
      Parameter name: name
      at MongoDB.Driver.Builders.Query.In(String name, IEnumerable`1 values)
      at MongoDB.Driver.Linq.PredicateTranslator.BuildMethodCallQuery(MethodCallExpression methodCallExpression)
      at MongoDB.Driver.Linq.PredicateTranslator.BuildQuery(Expression expression)
      at Test.TestClass.<>c_DisplayClass4.<TestMethod>b_3(QueryBuilder`1 query) in c:\dev\TestClass.cs:line 44
      at MongoDB.Driver.Builders.UpdateBuilder`1.Pull[TValue](Expression`1 memberExpression, Func`2 elementQueryBuilderFunction)
      . . .

      My guesses:
      It fails when calling query.Where() with lambda expression having no property access: p => participants.Contains(p). (p is a scalar value and used directly by its value). If I change the lambda to some complex object that has a property then it works: query.Where(complexObject => participants.Contains(complexObject.ParticipantNumber)). It seems that the query translator is able to translate expressions with properties only.

            Assignee:
            Unassigned
            Reporter:
            Neleus
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: