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

KeyNotFoundException on accessing GetLastErrorResult.DocumentsAffected property

      Unable to find source-code formatter for language: cs. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
                  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".

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

              Created:
              Updated:
              Resolved: