应用工作单元模式
我在企业应用程序架构模式中读到,工作单元只能在单个会话中使用。 因此每个会话都应该有其唯一的工作单元。 谁能告诉我为什么我不能对整个应用程序使用一个工作单元(在我的例子中是 ASP.NET)。
I have read in Patterns of Enterprise Application Architecture that a Unit Of Work should only be used in a single Session. So each session should have its only Unit Of Work. Can anybody tell me why I could not use one Unit Of Work for the whole application (in my case ASP.NET).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
工作单元模式的一半是跟踪事务中的更改,您当然可以跟踪整个应用程序的更改(这似乎很常见),但另一半是并发问题的解决方案,如果您将模式应用于整个应用程序,而不是在每个会话级别。
另外,在某些时候,您必须决定“嘿,这是一个单位...提交时间”,并且当考虑到整个应用程序且不同用户同时执行不同的操作时,这可能会很困难。
Half of the unit of work pattern is to keep track of changes in a transaction and you could certainly track that for an entire application (this seems to be pretty common) but the other half is the resolution of concurrency problems which becomes meaningless if you are applying the pattern to the entire application rather than on a per session level.
Also, at some point you have to decide "Hey this is a unit...time to commit" and that might be difficult when taking the whole application into account with different users doing different things at the same time.