【发布时间】:2011-01-11 19:58:56
【问题描述】:
是否建议使用自引用泛型继承?
public abstract class Entity<T> {
public Guid Id {get; set;}
public int Version {get; set;}
public T Clone() {
...
// clone routine
...
return T;
}
}
public class Customer : Entity<Customer> {
public string CustomerName {get; set;}
...
}
如何将 Customer 转换为基 Entity 类? “客户:实体”提供什么优势?我在展示 NHibernate 域建模的示例中看到了这种继承。
在没有泛型的情况下使用“客户:实体”会更好吗?
【问题讨论】:
标签: c# nhibernate generics inheritance