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

LINQ is not working as intended

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Works as Designed
    • Icon: Minor - P4 Minor - P4
    • None
    • 2.5
    • Linq
    • Windows 10, .NET 4.7.1
    • Fully Compatible

    Description

      The following code works:

      var dataCollection = Db.GetCollection<User>("User");
      var results = dataCollection.AsQueryable().Where(p => p.Id == userId);
      

      but it doesn't work if you do it like this:

      var dataCollection = Db.GetCollection<User>("User");
      var query = dataCollection.AsQueryable();
       
      query.Where(p => p.Firstname == "Tom");
      query.Where(p => p.Lastname == "Smith");
      

      it seems if its not part of the original variable, then mongo LINQ will totally ignore it

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            elomonaco Ed Lomonaco
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: