3
有没有办法在继承类型中产生返回类型的逆变?请参阅下面的示例代码。我需要这个实体框架。继承的逆变
public class InvoiceDetail
{
public virtual ICollection<Invoice> Invoices { get; set; }
}
public class SalesInvoiceDetail : InvoiceDetail
{
//This is not allowed by the compiler, but what we are trying to achieve is that the return type
//should be ICollection<SalesInvoice> instead of ICollection<Invoice>
public override ICollection<SalesInvoice> Invoices { get; set; }
}