I have a class, and I declare it like this:
public class WhereOrCondition<T> : WhereCondition<T>
The generic type T is the same for both classes. I am not sure how to declare my classes correctly so that the Generic type used for WhereOrCondition is also used in WhereCondition.
Declaring my class in this way gives me the following error:
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'.
Any ideas on how I can declare my class correctly?
EDIT
The WhereCondition class is declared like so:
public class WhereCondition<T> : IEnumerable<KeyValuePair<string, object>> where T : DatabaseObject
You need to put the same where condition on
WhereOrCondition<T>so it looks likeThe rule is a where clause on a sub class must be the same or more restrictive than a where clause on a base class.
What this says is
WhereOrCondition<T>hasWhereCondition<T>for a sub class andTmust be aDatabaseObject(or a subclass).Your code in the comment
public class WhereAndCondition<T> where T: WhereCondition<T>is something completly different. That says thatTmust be aWhereCondition<T>which cannot be true.