EF 4.1代码中的UnitOfWork和GenericRepository模式是否是冗余的? [英] Is UnitOfWork and GenericRepository Pattern redundant In EF 4.1 code first?

查看:75
本文介绍了EF 4.1代码中的UnitOfWork和GenericRepository模式是否是冗余的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想知道是否需要使用Genericrepository模式和UnitOfWork来模拟存储库.我正在使用MOQ.由于我注意到EF 4.1具有IDBSet,因此现在是多余的.

Wondering if I need to use the Genericrepository pattern and UnitOfWork to mock the repository.I am using MOQ.Is it now redundant since I have noticed that EF 4.1 has IDBSet.

我还没有弄清楚如何编写通用的IDBSet.如果您有实现IDBSet的示例,可以向我展示吗?

I have not figured out how to write something generic that usic IDBSet .If you have an example where you implement IDBSet can you show it to me?

有什么建议吗?

推荐答案

这是已经在SO上讨论过的许多主题的重复,但是我同意其中一些主题可能很难找到,因为它们嵌套在其他问题中

This is duplicate of many topics already discussed on SO but I agree that some of them can be hard to find because they are nested in other question

  • What's the point of Generic repository in EF 4.1
  • Challenges with testable and mockable code in EF
  • Another question about challenges with mocking EF code
  • Implementing custom IDbSet
  • Another question resulting in discussion about repository and unit of work

我希望这会给您一些答案.如果没有,请在这里或在新问题中询问更多信息.

I hope this will give you some answers. If not, don't hesitate to ask for more information either here or in a new question.

这篇关于EF 4.1代码中的UnitOfWork和GenericRepository模式是否是冗余的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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