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

Make collection parameter optional in constructor for MongoInsertOptions and MongoUpdateOptions

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.4
    • Affects Version/s: 1.3.1
    • Component/s: None
    • None
    • Major Change

      The constructors for MongoInsertOptions and MongoUpdateOptions take a collection parameter for the purpose of inheriting some of the values from the collection. But this results in having to specify the collection twice in code like the following:

      var options = new MongoInsertOptions(collection) { SafeMode = SafeMode.W2 };
      collection.Insert(document, options);
      

      It would be nicer (and shorter) to just write:

      var options = new MongoInsertOptions { SafeMode = SafeMode.W2 }; // no collection parameter
      collection.Insert(document, options);
      

      This does mean that the options class will NOT be filled in with default values from the collection, so the properties of the options class will be null unless set to a value by your code. The collection class will know to fetch default values from the collection for any values to explicitly set in the options class.

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

              Created:
              Updated:
              Resolved: