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

MongoDBRef getting from undefined type(with bsondocument)

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • 1.7.1
    • Feature Request
    • None
    • new driver method

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: