hi.
i’m trying to create a a document from a class created runtime.
let me show what i have
this is my classes
[BsonDiscriminator("File")]
[BsonIgnoreExtraElements]
public class BsonFile
{
[BsonElement]
public BsonEntry[] _entries;
}
[BsonDiscriminator("Entry")]
[BsonIgnoreExtraElements]
public class BsonEntry
{
[BsonId]
public string _classID {get; set;}
[BsonDictionaryOptions(DictionaryRepresentation.Document)]
public Dictionary<string,BsonArray> _dictionary {get; set;}
}
and this is what i do
BsonFile file =
new BsonFile();
file._entries =
_propDic.Values.ToArray();
writer.WriteStartDocument();
var entry = file.ToBsonDocument();
var bson = BsonDocument.Create(entry);
doc.Add(bson);
writer.WriteEndDocument();
where _propDic is contains the array of BsonEntry that will be stored in the BsonFile class.
what i’m doing wrong?