Hi,
I have this problem when try to Save my entity...
System.InvalidCastException: Unable to cast object of type
'NHibernate.Collection.Generic.PersistentGenericBag`1[Domain.Model.Menu]'
to type 'System.Collections.Generic.List`1[Domain.Model.Menu]
NHibernate.PropertyAccessException: Invalid Cast (check your mapping
for property type mismatches); setter of Domain.Model.Menu
at
NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValuesWithOptimizer(Object
entity, Object[] values)
My class / mapping is:
public class Menu: Entity
{
public virtual Menu ParentMenuItem {get;set;}
public virtual List<Menu> MenuItems {get;set;}
...
}
and mapping:
mapper.Class<Menu>(map =>
{
map.Bag(x => x.MenuItems, cm =>
cm.Key(km => km.Column("ParentMenuItem_Id")),
m => m.OneToMany());
map.ManyToOne(x =>
x.ParentMenuItem, m => m.Column("ParentMenuItem_Id"));
});
What am I doing wrong?
I want to map Menu with sumbmenues it is a one-to-many to self
relation.
The exception happens on Session.Save(menu);
Please help.
--
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.