MongoDB.Driver.Database.FollowReference C# (CSharp) Method

FollowReference() public method

Gets the document that a reference is pointing to.
public FollowReference ( DBRef reference ) : Document
reference DBRef
return Document
        public Document FollowReference(DBRef reference)
        {
            if(reference == null) throw new ArgumentNullException("reference cannot be null");
            Document query = new Document().Append("_id", reference.Id);
            return this[reference.CollectionName].FindOne(query);
        }

Usage Example

Ejemplo n.º 1
0
        public void TestFollowNonReference()
        {
            Database tests = mongo["tests"];
            Oid      id    = new Oid("BAD067c30a57000000008ecb");
            DBRef    rf    = new DBRef("reads", id);

            Document target = tests.FollowReference(rf);

            Assert.IsNull(target, "FollowReference returned wasn't null");
        }
All Usage Examples Of MongoDB.Driver.Database::FollowReference