【发布时间】:2020-03-25 15:43:30
【问题描述】:
我已将文档插入到 MongoDB 的集合中
public class Product :BaseDocument, IProduct
{
public Guid ProductId { get; set; }
public string ProductName { get; set; }
public Guid AccountId { get; set; }
public List<IProductDetail> ProductDetailList { get; set; } = new List<IProductDetail>();
}
public class ProductDetail:IProductDetail
{
public Guid ProductDetailId { get; set; }
public string ProductDetailCode { get; set; }
}
当我尝试检索这个时,我得到一个错误
public List<IProduct> GetProductsList(Guid accountId)
{
IEnumerable<IProduct> prodList = new List<Product>();
IMongoCollection<Product> products = _database.GetCollection<Product>("Products");
prodList = products.Find(m => m.AccountId == accountId).ToList();
return prodList.ToList();
}
报错如下
System.FormatException: '反序列化时出错 Entities.ProductDetail 类的 ProductDetailList 属性:未知 鉴别器值'ProductDetail'。'
我做错了什么?
【问题讨论】:
标签: c# .net mongodb mongodb-.net-driver