with NH you can setup cascade which will save the child when the parent is 
saved.
//open session
//begin transaction;

var child = new child();
var parent = new parent();
parent.Add(child);
session.Save(parent);

//commit transaction
//dispose of session

if you where to retrieve the parent from the session the session the is 
event simpler
//open session
//begin transaction;

var child = new child();
var parent = session.Get<Parent>(id);
parent.Add(child);

//commit transaction
//dispose of session

some things to note about NH.
1. all calls should be wrapped in a transaction (reads and writes)
2. you should rarely, if ever need to call session.Flush(); this is low 
level code for NH. by committing a transaction the session will be flushed. 
(unless you alter the defaults)
3. NH prof <http://www.nhprof.com> is an excellent profiler which will allow 
you to see what NH is doing. it will also warn you about improper usage of 
NH.
4. I recommend reading about NH id generators. It's important to understand 
how NH is designed, vs how NH will behave with database ids (like MS SQL 
Identity)
The top three articles on google are 
great<http://www.google.com/search?q=nhibernate+poid>

-- 
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