Created
April 22, 2013 20:23
-
-
Save beyond-code-github/5438185 to your computer and use it in GitHub Desktop.
Implementation of BsonDocument backed class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using MongoDB.Bson; | |
using MongoDB.Bson.Serialization; | |
using MongoDB.Bson.Serialization.Attributes; | |
[Serializable] | |
[BsonSerializer(typeof(MongoDocumentClassSerializer))] | |
public class MongoDocument : BsonDocumentBackedClass | |
{ | |
public MongoDocument() | |
: base(new MongoDocumentClassSerializer()) | |
{ | |
} | |
public MongoDocument(BsonDocument backingDocument) | |
: base(backingDocument, new MongoDocumentClassSerializer()) | |
{ | |
} | |
public MongoDocument(BsonDocument backingDocument, IBsonDocumentSerializer serializer) | |
: base(backingDocument, serializer) | |
{ | |
} | |
[BsonId] | |
public ObjectId Id { get; set; } | |
public BsonValue this[string fieldname] | |
{ | |
get | |
{ | |
return this.BackingDocument[fieldname]; | |
} | |
set | |
{ | |
this.BackingDocument[fieldname] = value; | |
} | |
} | |
public static implicit operator BsonDocument(MongoDocument document) | |
{ | |
return document.BackingDocument; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment