How do you save collections?

19 views
Skip to first unread message

Aung

unread,
Oct 6, 2009, 7:58:59 PM10/6/09
to Fluent NHibernate
Hi,
I'm just starting to learn NHibernate so I haven't gone through all
the reference documents yet.
I have been using LLBLGen before so I'm a bit spoiled. LLBLGen had a
SaveEntityCollection method that just let me drop a collection of
entities and it does the saving.

Is there a save collection method in NHibernate or do I have to loop
through my collection and call save for every entity?
Oh and if there is a manual with all the best practices for Fluent
NHibernate, please let me know.

Thanks,
Aung.

Hudson Akridge

unread,
Oct 6, 2009, 8:19:21 PM10/6/09
to fluent-n...@googlegroups.com
You're looking for cascades. Save the parent entity, and any entities that are contained as part of a collection, also get saved. Different cascade types depending on what you need.

What you also may be talking about, is how to save objects retrieved during a session (your Unit of Work). The answer? Commit the transaction. NH keeps track of all of objects retrieved in memory, and will persist them at the end of the session/transaction automatically.

Check out wiki.fluentnhibernate.org/ for your best practices needs.
Reply all
Reply to author
Forward
0 new messages