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

Linq doesn't support "In" clause

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.5
    • Affects Version/s: 1.4.2
    • Component/s: None
    • None

      public sealed class Document
      {
      public string Id

      { get; set; }
      public List<string> Folders { get; set; }

      }
      public sealed class Folder
      {
      public string Id

      { get; set; }

      }

      1. var documentFolders = documentCollection.AsQueryable().Where(x => x.Id == "document1").Select(x => x.Folders).Single();
      2. var folders = folderCollection.AsQueryable().Where(x => documentFolders.Contains(x.Id)).ToArray();
      3. Got this ArgumentException:
      Unsupported where clause: System.Collections.Generic.List`1[System.String].Contains(x.Id).

      Stack trace:

      at MongoDB.Driver.Linq.SelectQuery.BuildQuery(Expression expression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 862
      at MongoDB.Driver.Linq.SelectQuery.BuildQuery() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 123
      at MongoDB.Driver.Linq.SelectQuery.Execute() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 132
      at MongoDB.Driver.Linq.MongoQueryProvider.Execute(Expression expression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\MongoQueryProvider.cs:line 147
      at MongoDB.Driver.Linq.MongoQueryable`1.GetEnumerator() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\MongoQueryable.cs:line 81
      at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
      at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
      at DAL.MyService.MyMethod(String rId) in D:\file1.cs:line 176
      at DynamicModule.ns.Wrapped_INavigationServiceRepository_364d6b61519c4b838c96d681fbc90833.<GetObjectParents_DelegateImplementation>__1(IMethodInvocation inputs, GetNextInterceptionBehaviorDelegate getNext)

        There are no Sub-Tasks for this issue.

            Assignee:
            craig.wilson@mongodb.com Craig Wilson
            Reporter:
            gfx00 Brian
            Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: