打破对实体框架的依赖
我终于有了一个我认为结构非常好的项目。在阅读了 Fowler 的洋葱架构、学习了 IOC/DI 的 Ninject 并调整了我的 Psuedo 存储库类之后,我使用 EF 4.1,因此 DbSet 和 DbContext 提供了存储库的大部分内容;当我想要在我的存储库中“包含”其他实体/相关实体时,我现在面临着对实体框架的令人恼火的依赖。
有人对如何打破这种依赖性有任何建议吗? 例如,我有一个服务层,一旦我决定使用 .Ininclude,就会调用存储库,我就绑定到又胖又重的实体框架...我应该使用 .Join 还是可以以某种方式抽象 EF?
I have, what I think is a very well structured project, finally. After reading Fowler's onion architecture, learning Ninject for IOC/DI and tweaking my Psuedo repository classes, I am using EF 4.1 so DbSet and DbContext supply the repository for the most part; I am now faced with the irritating dependency on Entity Framework when wanting to "Include" other Entities / Related Entities in my repository.
Does anyone have any suggestions on how to break this dependency?
For example, I have a service layer that makes calls to Repository As soon as I decide to use .Include I am bound to the fat and heavy Entity Framework... Should I go with .Join or can EF be abstracted in some way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Julie Lerman 在她的博客上发表了一篇文章,其中展示了
IQueryable
上的 Include 扩展方法,该方法允许您在代码中使用 Include 且不会破坏单元测试:请在此处查看她的完整博客文章:
敏捷实体框架 4 存储库第 5 部分: IObjectSet 和 Include
Julie Lerman has a post on her blog where she shows an Include extension method on
IQueryable<T>
, which allows you to use Include in your code and not break your unit tests:See her full blog post here:
Agile Entity Framework 4 Repository Part 5: IObjectSet and Include