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

Search by condition with method Any (Linq) returns 0 documents when filter has OR condition

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Linq, LINQ3
    • Labels:

      1) List<PartyUser> users1 = userRepository.GetList(c => c.Roles.Any(r => r == UserRoles.Admin));

      2) List<PartyUser> users2 = userRepository.GetList(c => c.Roles.Any(r => r == UserRoles.Admin || r == UserRoles.Editor));

       

      First line returns 3 elements, but second line is 0, even it has wider filter and there a lot of documents with UserRoles.Editor.

       

      public List<T> GetList(Expression<Func<T, bool>> where)

      { return Db.GetCollection<T>(CollectionName).Find(where).ToList(); }

      Where Db is IMongoDatabase

      2.7.0 Beta1

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            rbuchyn Roman Buchyn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: