winforms - UnitOfWork in action -


I want you to present the application scenario to your windows:

I want to make an invoice, So I open a new window with the invoice details. Then I want to add a new customer (in the database), that I want to use in my invoice. After entering all the information (including new customer information) I click Save to save my new document. Question: Should I do all the work in a NH session? So save the new customer and save the invoice in one unit of work.

Or should the new customer be saved separately? If so, if I add a new customer and click on canceling the invoice details, the invoice creation can be canceled, but the customer is still in the database.

I use a unit of work for the whole conversation, maybe I'm wrong.

Should I do all the work in a NH session? So save the new customer and save the invoice in one unit of work.

Yes, use a NHibernate session Mapping the unit of life of a session is usually the easiest way.

Do not confuse sessions with transactions. If you fail to create a creation, then you want to roll back both the creations, for which transaction is required and nothing with the NHibernate session Is (mostly).


Comments