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

KeyNotFoundException on accessing GetLastErrorResult.DocumentsAffected property

    XMLWordPrintableJSON

Details

    Description

                  var coll = new MongoClient("mongodb://localhost:27017/").GetServer().GetDatabase("driverBug").GetCollection("coll0");
                  coll.Drop();
                  coll.CreateIndex(IndexKeys.Ascending("fld0"));
                  try
                  {
                      coll.CreateIndex(IndexKeys.Ascending("fld0"), IndexOptions.SetSparse(true));
                  }
                  catch (WriteConcernException ex)
                  {
                      Console.WriteLine(ex.WriteConcernResult.DocumentsAffected); // XXX
                  }

      "KeyNotFoundException" at line "XXX". I assume that "DocumentsAffected" is not relevant to index creation errors so "InvalidOperationException" or "NotSupportedException" should be thrown in this case. Or maybe return zero, but not "KeyNotFoundException".

      Attachments

        Activity

          People

            Unassigned Unassigned
            proman Pantyushin Roman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: