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
    • Fully Compatible
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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:
            6 Start watching this issue

              Created:
              Updated: