数据库对象的工作单元是什么?
通俗地说,什么是数据库对象的工作单元?我正在研究如何将数据库表转换为 C# 类,并且经常遇到这个术语,但每个人似乎都在描述它,好像您应该已经知道它是什么一样。
In layman's terms, what is a unit of work in regards to database objects? I'm researching how to convert database tables into C# classes and I frequently come across this term, but everyone seems to describe it as if you should already know what it is.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我将在这里引用Martin Fowler,因为我认为他的含义是最清晰、最容易理解的之一我见过:
I'll quote Martin Fowler here, since I think his meaning is one of the clearest, most comprehensible I've seen:
基本上,它意味着完成原子操作所需的工作,例如在两个支票账户之间转账。
示例(伪代码)
这里有一篇描述工作单元和持久性无知的优秀 MSDN 文章:
http://msdn.microsoft.com/en-us/magazine/dd882510。 ASPX
Basically it means the work required to complete an atomic action, e.g. transferring money between two checking accounts.
Example (in pseudocode)
A good MSDN article describing Unit of Work and Persistence Ignorance is here:
http://msdn.microsoft.com/en-us/magazine/dd882510.aspx
在 LINQ to SQL 中,工作单元定义为 (http://msdn. microsoft.com/en-us/library/bb546187.aspx):
了解工作单元对于成功使用 LINQ to SQL 非常重要。查看此页面(更新场景),了解工作单元模式如何适应 LINQ to SQL:
http ://aspalliance.com/1414_LINQ_to_SQL_Part_4__Updating_our_Database.3
Martin Fowler 的《企业架构模式》一书有相当多的页面专门讨论该主题(第 184-194 页)。他的简短定义是:
In LINQ to SQL a unit of work is defined as (http://msdn.microsoft.com/en-us/library/bb546187.aspx):
Understanding the unit of work is important for success with LINQ to SQL. Have a look at this page (A update scenario), for how the unit of work pattern fits into LINQ to SQL:
http://aspalliance.com/1414_LINQ_to_SQL_Part_4__Updating_our_Database.3
Martin Fowler's Patterns of Enterprise Architecture book has quite a few pages devoted to the topic (pg 184-194). His brief definition is: