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

Ambiguity in MongoDB.Driver.Builders.Update.AddToSetEach methods

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.2
    • Affects Version/s: 1.1
    • Component/s: None
    • None

      Visual Studio 2010, Target Framework .NET 3.5 (driver 1.1 - both official API and built from the latest sources).

      This code cannot be compiled:

      void TestCompilerError()

      { var bsonArray = new MongoDB.Bson.BsonArray(); var update = MongoDB.Driver.Builders.Update.AddToSetEach("Name", bsonArray); }

      Error: The call is ambiguous between the following methods or properties: 'MongoDB.Driver.Builders.Update.AddToSetEach(string, System.Collections.Generic.IEnumerable<MongoDB.Bson.BsonValue>)' and 'MongoDB.Driver.Builders.Update.AddToSetEach(string, params MongoDB.Bson.BsonValue[])'

      The couple of methods were apparently added for convenience in some cases. But it also makes problems in other cases. Perhaps the issue was known and the choice was done. If not, perhaps it makes sense to review and revise this API.

      (N.B. Just in case, this case of ambiguity is different from https://jira.mongodb.org/browse/CSHARP-280)

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

              Created:
              Updated:
              Resolved: