NHibernate Collection Mapping - Read Only Properties
Posted
by Chris Meek
on Stack Overflow
See other posts from Stack Overflow
or by Chris Meek
Published on 2010-03-31T12:10:50Z
Indexed on
2010/03/31
12:13 UTC
Read the original article
Hit count: 311
nhibernate
I have the following class
public class Person
{
private IList<Person> _children;
public IEnumerable<Person> Children { get; }
public void AddChild(Person child)
{
// Some business logic and adding to the internal list
}
}
What changes would I have to make for NHibenrate to be able to persist the Child collection (apart from making everything virtual, I know that one).
Do I have to add a setter to the children property which does something like a _children.Clear(); _children.AddRange(value)
. Currently the model expresses my intent quite nicely but I'm not sure how much alteration is need for NH to be able to help me out with persistence.
© Stack Overflow or respective owner