C#中的继承和泛型有问题

use*_*041 2 c# generics inheritance

我有一个班级,我这样声明:

public class WhereOrCondition<T> : WhereCondition<T>
Run Code Online (Sandbox Code Playgroud)

T两个类的泛型类型相同.我不确定如何正确声明我的类,以便WhereOrCondition也使用用于的通用类型WhereCondition.

以这种方式声明我的课给我以下错误:

Error 1 The type 'T' cannot be used as type parameter 'T' in the generic type or method 'BrainStorm.WhereCondition<T>'. There is no boxing conversion or type parameter conversion from 'T' to 'BrainStorm.DatabaseObject'.

关于如何正确宣布我的课程的任何想法?

编辑

WhereCondition类被声明如下所示:

public class WhereCondition<T> : IEnumerable<KeyValuePair<string, object>> where T : DatabaseObject 
Run Code Online (Sandbox Code Playgroud)

Ray*_*Ray 7

你需要在相同的条件下放置WhereOrCondition<T>它所以它看起来像

public class WhereOrCondition<T> : WhereCondition<T> where T: DatabaseObject
Run Code Online (Sandbox Code Playgroud)

规则是子类的where子句必须与基类的where子句相同或更严格.

它说的是WhereOrCondition<T>WhereCondition<T>一个子类T必须是一个DatabaseObject(或子类).

您在评论中的代码public class WhereAndCondition<T> where T: WhereCondition<T>完全不同.那说T必须是一个WhereCondition<T>不可能是真的.