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

MongoDBRef getting from undefined type(with bsondocument)

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 1.7.1
    • Component/s: Feature Request
    • Labels:
      None
    • Environment:
      new driver method

      now I fetch dbref by following code:
      BsonDocument doc = test.FindOne();
      var l = doc.Elements.ElementAt(1);
      var linkr=l.Value;//dbref there
      MongoDBRefSerializer ser=new MongoDBRefSerializer();
      BsonReader reader = BsonReader.Create(linkr.ToJson());
      var refrefref= ser.Deserialize(reader, typeof(MongoDBRef), new opt());
      MongoDBRef a = (MongoDBRef)refrefref;
      var referenced = db.FetchDBRef(a);

      opt class
      class opt : IBsonSerializationOptions
      {
      public void ApplyAttribute(IBsonSerializer serializer, Attribute attribute)

      { throw new NotImplementedException(); }

      public IBsonSerializationOptions Clone()
      { throw new NotImplementedException(); }

      public IBsonSerializationOptions Freeze()

      { throw new NotImplementedException(); }

      }
      i dont know why code so long and there is a lot of unnessesary types?

      i think it would be better to add following method to fetchdbref:
      BsonDocument doc = test.FindOne();
      var l = doc.Elements.ElementAt(1);
      var linkr=l.Value;//dbref there
      MongoDBRef refer = linkr.AsDBRef() //
      var profit = db.FetchDBRef(refer);

      if possible.
      thank you.

            Assignee:
            Unassigned Unassigned
            Reporter:
            stormbringer1984 ??????? ??????? ???????
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: