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

Find by Id - such a common task, should there be a method for it on MongoCollection<T>?

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 0.9
    • Affects Version/s: 0.7
    • Component/s: Feature Request
    • Labels:
      None
    • Environment:
      N/A

      It seems that loading an object by it's ID is a very common task. This leads to a lot of repetitive code. If a MongoCollection provided a FindOneById(ObjectId id) method that duplicate code could be eliminated.

      In MongoCollection.cs on MongoCollection<T>

      public TDefaultDocument FindOneById (ObjectId id)

      { return FindOne(Query.EQ("_id", id)); }

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            ianmercer Ian Mercer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: