我从MongoDB中的集合得到结果,结构如下
[DataContract]
public class Father
{
[BsonId]
[DataMember]
public MongoDB.Bson.ObjectId _id { get; set; }
[DataMember]
public string Id { get; set; }
[DataMember]
public List<Child> childs { get; set; }
}
[DataContract]
public class Child
{
[DataMember]
public string Id { get; set; }
[DataMember]
public int Name { get; set; }
}
当我尝试这个时:
List<Father> f = result.ToList();
它调用 Element 'Id' does not match any field or property of the class Model.Child
我认为它只是把'Id'当作别的东西。
我该如何处理?谢谢