实体框架自我跟踪实体与工作单元 [英] Entity framework self tracking entities vs Unit of work

查看:68
本文介绍了实体框架自我跟踪实体与工作单元的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Entity框架自我跟踪实体和实现工作单元架构有什么区别?据我所知,两者都是跟踪对象,一个db调用提交更改。所以我无法弄清楚那些差异。有人可以指出我在哪种情况下应该使用什么?

我正在使用实体框架5和WCF服务应用程序。

What is the difference between using Entity framework self tracking entities and implementing Unit of work architecture? As i understand both are keep tracking of the objects, one db call for commit changes. So i cant figure out the difference of those. can some one point me about what should used in which case?
I'm using entity framework 5 with WCF service application.

推荐答案

实体框架自我跟踪是一种工作单元。

关于工作单位和工作单元的更多链接

http://stackoverflow.com/questions/6843006/is-工作单元模式所需的实体框架-4-0

http://stackoverflow.com/questions/7940854/is-unit-of-work-and-repository -patterns-非常有用的大项目#7941017
Entity framework self tracking is a kind of unit of work.
more link about ef and unit of work
http://stackoverflow.com/questions/6843006/is-unit-of-work-pattern-required-in-entity-framework-4-0
http://stackoverflow.com/questions/7940854/is-unit-of-work-and-repository-patterns-very-useful-for-big-projects#7941017


我已经找到你的回答,很清楚要理解答案:

1-当你看到它们的目的时,它们是相同的,因为它们会将所有变化一起变为数据库。

2-你可以选择自我跟踪,因为:自我跟踪只需准备好与各种工作能力一起使用(因为它有很多实现的方法)

3-你可以优先选择UnitOfWork,因为:你可以添加你的方法满足您的需求,如RoleBack,但如果您同意当前的实施,也可以将这些添加到selftracking



:)
I have find out your response it is very clear to understand the answer:
1- They are the same when you look thir purpose because they will aply the changes all together to the databse
2- You can prefere Self Tracking because: Self Tracking simply ready to use with a variety of working capasity (Because it has many implemented methods)
3- You can prefere UnitOfWork because: You can add your methods according to your needs as like as RoleBack but also you can add those to the selftracking if you agree current implementation

:)


这篇关于实体框架自我跟踪实体与工作单元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆