5
내가 할 때이 같은다형성 문제
[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();
작동하지만, 수업을 내가 InvalidCastException이 얻을
var item = mongo.GetCollection<Content>().AsQueryable().FirstOrDefault();
같은 쿼리
Object must implement IConvertible.
무엇이 잘못 되었나요? 지역을 콘텐츠로 변환하는 것이 문제가되어서는 안됩니다. IConvertible을 구현하려면 실제로 콘텐츠를 만들어야합니까?