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

ICollection<T>.Contains is not supported in a LINQ Expression

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.8.2
    • Affects Version/s: 1.8.1
    • Component/s: None

      This unit test works when you declare the type as int[], but not when you declare the type as IList<int>.

      I believe this also affects LINQ expressions using Contains or In. IEnumerable, array types, and List types are supported but IList throws an Unsupported exception.

      [Test]
      public void TestInExpressionWithIList()
      {
          IList<int> list = new[] { 2, 4, 6 };
          var query = Query<A>.Where(a => list.Contains(a.X));
          var expected = "{ \"x\" : { \"$in\" : [2, 4, 6] } }";
          Assert.AreEqual(expected, query.ToJson());
      }
      

            Assignee:
            craig.wilson@mongodb.com Craig Wilson
            Reporter:
            zaidmasud Zaid Masud
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: