English 中文(简体)
UnitOfWorks in action
原标题:UnitOfWork in action

我想向各位介绍我的窗口构成应用情景:

我想制造一张发票,因此,我打开有发票细节的新窗口。 然后我想在我的发票中增加新的客户(数据库)。 在输入所有信息(包括新的客户信息)之后,我点击“拯救”我的新文件。

The question is: should I do all the work in one NH session? So saving new customer and saving invoice in one unit of work.

或许可以单独拯救新的客户? 如果是的话,如果我增加新的客户并点击发票细节表格的注销,那么发票的开销就会取消,但客户仍在数据库中。

我用一个工作单位进行整个对话。 也许我错了。

最佳回答

should I do all the work in one NH session? So saving new customer and saving invoice in one unit of work.

是的,使用一次NHibernate会议。 把本届会议的工作时间描绘成一个单一的工作单位,一般是最容易去做的。

• 安排会议与交易。 如果一个创作失败,你就希望收回两个创作,这就要求交易,并且(主要是)与自由会议无关。

问题回答

从逻辑上讲,在工作股创建客户,然后在另一个单位制造发票是明智的。 然而,由于您似乎希望客户和<>>m>的发票的制作合在一起成为原子,因此在一项承诺中设定发票是合理的。

我不知道NHibernate如何与这些协会打交道,尽管——如果要让客户与发票挂钩,那么你别无选择,只能在创建客户,然后制造发票。

每项商业交易的争议是你的朋友:

The code is in unhaddins, and we have two examples for desktop applications. One of them is my "Chinook Media Manager" (look for the posts on google). There is also an implementation using PostSharp in unhaddins s trunk.





相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.