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

MongoDBRef getting from undefined type(with bsondocument)

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Works as Designed
    • Affects Version/s: 1.7.1
    • Fix Version/s: None
    • Component/s: Feature Request
    • Labels:
      None
    • Environment:
      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

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: