Generic EntityCollection issue

Posts   
 
    
mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 15-Aug-2007 02:47:32   

I am using the 2.5 Beta, although I think this problem relates to 2.0 as well.

I am trying to write custom code in the generic EntityCollection generated class. Inside this custom code, I am trying to use functionality that I have written into CommonEntityBase. However, the generic collection is constrained to type EntityBase2 instead of CommonEntityBase. Shouldn't this be constrained to type CommonEntityBase, as all generated entities inherit off this class? (I think this may be true for only 2.5, but possible in 2.0 as well).

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 15-Aug-2007 09:15:37   

In v.2.5 the entity classes inherits from CommonEntityBase which in turn inherits from EntityBase(2).

Generic Entity Collections still accepts objects of Type EntityBase(2) for backward compatability, to avoid breaking older code.

Since objects added to the generic collection are of type CommonEntityBase, then I suppose you may down-cast (from EntityBase(2) to CommonEntityBase) .