Ups.... if so a generic class would be better
BaseClass<T>
 public virtual IColllection<T> Collection { get;set; }

ChildClass: BaseClass<ChildClassCollection>

then you can map the collection to internal field and use Linq OfType<T> to
return the expected strongly-typed enumerable.
Obviously there are others solutions without use 'new'.

2010/1/30 Diego Mijelshon <[email protected]>

> He can't use override because he's trying to restrict the type of the
> children...
>
>    Diego
>
>
> On Sat, Jan 30, 2010 at 13:49, Fabio Maulo <[email protected]> wrote:
>
>> I'm sorry...
>> a simple 'override' instead a 'new' would be not enough ?
>>
>> btw I hope this "problem" is not for an auto-property
>>
>> 2010/1/28 roend <[email protected]>
>>
>> I have an inheritance structure that looks something like this:
>>>
>>> public class BaseClass
>>> {
>>>    public virtual IColllection<BaseClassCollection> Collection { get;
>>> set; }
>>> }
>>>
>>> public class ChildClass : BaseClass
>>> {
>>>    public new virtual ICollection<ChildClassCollection> Collection
>>> { get; set; }
>>> }
>>>
>>> Is there a way with a joined subclass mapping to make this work.
>>>
>>> There error I'm getting is:
>>>
>>> {"Unable to cast object of type
>>> 'NHibernate.Collection.Generic.PersistentGenericBag`1
>>> [BaseClassCollection]' to type
>>> 'System.Collections.Generic.ICollection`1[ChildClassCollection]'."}
>>>
>>> I get this error when I try to get a ChildClass instance from the
>>> database.
>>>
>>> Any ideas?
>>>
>>> Thanks,
>>> Nathan
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "nhusers" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<nhusers%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/nhusers?hl=en.
>>>
>>>
>>
>>
>> --
>> Fabio Maulo
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "nhusers" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<nhusers%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/nhusers?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>



-- 
Fabio Maulo

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to