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

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.2.2, 2.2.3
    • Component/s: API, Performance
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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 Stam
              Reporter:
              Juan Antonio
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: