我正在学习Nhibernate 3.0。在其中一个示例代码中,它创建了一个抽象的基本实体类:
public abstract class Entity<T> where T : Entity<T>
然后,让Customer
实体继承自Entity
基类:
public class Customer : Entity<Customer>
我理解它是一个抽象的泛型类,并使用where
关键字确保类型T
是Entity<T>
,这就是我感到困惑的地方。
Customer
继承了"Entity<Customer>
",这个"Entity<Customer>
"将"Customer
"作为T
,但这个Customer
不是"Entity<T>
"。
请帮助我理解这一点,我对这个泛型类真的很困惑。