ISession Extension for Saving Multiple Objects

Incredibly simple, but quite useful:

        public static void Save(this ISession session, params object [] entities)
            foreach (var o in entities)

You can use it like:


with a list of objects of any type. Useful for unit testing where you want to save multiple items at once.


Probably should call it something other than Save, such as SaveAll or SaveList because if you only pass two items to the overload it calls the standard Save(object, int id) version. :(

This entry was posted in c#, NHibernate. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>