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

Linq queries are getting the right result, but hydrates more elements than expected.

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.2.2, 2.2.3
    • Component/s: API, Performance
    • None

      Hi all,

      Using c# driver through Linq expressions, we've noticed that many objects are hydrated when using AsQueryable() + Linq expresion even though the query returns one result.

      ...
      var collection = _mongoDatabase.GetCollection<User>("Users");
      var usersFound = collection.AsQueryable().Where(x => x.UserName == "John Doe");
      ...

      By the other hand, if we use Eq method, the behavior is the expected: there is only one object hydrated.

      ...
      var filter = Builders<User>.Filter.Eq("UserName", "John Doe");
      var usersFound = collection.Find(filter);
      ...

      Is that te implemented behaviour of the driver using Linq?

      Many thanks!

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            juananjato Juan Antonio
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: