我有课
[MongoDiscriminated]
public abstract class Content
{
public int? Id { get; set; }
public int? ParentId { get; set; }
public string Slug { get; set; }
public string Path { get; set; }
public string Title { get; set; }
}
public class Area : Content
{
}
像这样的查询有效
var item = mongo.GetCollection<Area>().AsQueryable().FirstOrDefault();
但是当我进行类似的查询时
var item = mongo.GetCollection<Content>().AsQueryable().FirstOrDefault();
我得到一个 InvalidCastException
Object must implement IConvertible.
怎么了?将 Area 转换为 Content 应该不是问题。我真的必须制作内容来实现 IConvertible 吗?