I would like to allow reparenting in Fluent NHibernate.
Here I read that I have to create two classes which inherit from IUserCollectionType
and PersistentGenericBag<MyClass>
. If I change Box
from the example to my own classname, everything works fine - except one thing: In the class which inherits from PersistentGenericBag<MyClass>
I can't override GetOrphans()
because Cast()
is not defined for an ICollection
.
This is what I would like to have:
public override ICollection GetOrphans(object snapshot, string entityName)
{
var orphans = base.GetOrphans(snapshot, entityName)
.Cast<MyCalss>()
.Where(b => ReferenceEquals(null, b.CurrentStorage))
.ToArray();
return orphans;
}
How can I use Cast
on an ICollection
?
Edit
This is the exact error I get (unfortunatly it's german): Fehler 1 "System.Collections.Generic.ICollection<T>" enthält keine Definition für "Cast", und es konnte keine Erweiterungsmethode "Cast" gefunden werden, die ein erstes Argument vom Typ "System.Collections.Generic.ICollection<T>" akzeptiert. (Fehlt eine Using-Direktive oder ein Assemblyverweis?)