【发布时间】:2016-07-04 17:59:45
【问题描述】:
我对 MongoDB 比较陌生。我有一个具有以下定义的对象
[BsonDiscriminator("user")]
public Class BrdUser
{
[BsonId(IdGenerator = typeof(StringObjectIdGenerator))]
public string ID { get; set; }
[BsonElement("username")]
public string UserNm { get; set; }
[BsonElement("email")]
public string EmailAdrs { get; set; }
.
.
.
public IList<Question> Questions{ get; set; } //<-- Un sure as to what Bson type should this be
}
Questions 是另一个 BsonDocument 定义为:
[BsonDiscriminator("userques")]
public class Question
{
[BsonId(IdGenerator = typeof(StringObjectIdGenerator))]
public string ID { get; set; }
[BsonElement("title")]
public string Title{ get; set; }
[BsonElement("desc")]
public string Desciption{ get; set; }
}
我的问题是在映射时,我应该使用什么属性以便用户对象与问题对象反序列化。 C#驱动中没有[BsonDocument]属性。
【问题讨论】:
-
你试过序列化对象吗?结果是什么?
-
我的问题是赋予 IList 什么属性
标签: c# asp.net-mvc mongodb mapping