天天看点

EntityFramework用法探索(五)引入Unity

在上文中,我们手工定义了CustomerRepository中DbContext的,

EntityFramework用法探索(五)引入Unity
EntityFramework用法探索(五)引入Unity

但如果表数量过多,手工编码会变得非常繁琐,使用IoC容器提供的功能来解决。

EntityFramework用法探索(五)引入Unity
EntityFramework用法探索(五)引入Unity

则在CustomerRepository中的配置会简介些,

EntityFramework用法探索(五)引入Unity
EntityFramework用法探索(五)引入Unity

显然同样的测试代码仍然可以工作,不再赘述。

EntityFramework用法探索系列

<a href="http://www.cnblogs.com/gaochundong/archive/2013/06/06/entityframework_usage_database_first.html">(一)DatabaseFirst</a>

<a href="http://www.cnblogs.com/gaochundong/archive/2013/06/06/entityframework_usage_code_first.html">(二)CodeFirst</a>

<a href="http://www.cnblogs.com/gaochundong/archive/2013/06/06/entityframework_usage_code_first_fluent_api.html">(三)CodeFirst流畅API</a>

<a href="http://www.cnblogs.com/gaochundong/archive/2013/06/06/entityframework_usage_repository_unitofwork.html">(四)Repository和UnitOfWork</a>

<a href="http://www.cnblogs.com/gaochundong/archive/2013/06/06/entityframework_usage_with_unity.html">(五)引入Unity</a>

<a href="http://www.cnblogs.com/gaochundong/archive/2013/06/06/entityframework_usage_static_repository.html">(六)静态Repository</a>

<a href="http://www.cnblogs.com/gaochundong/archive/2013/06/06/entityframework_usage_thread_scope.html">(七)线程安全实践</a>

<a href="http://www.cnblogs.com/gaochundong/archive/2013/06/09/entityframework_usage_transaction_scope.html">(八)事务处理</a>

<a href="https://github.com/gaochundong/WhenEntityFrameworkMeetUnity">完整代码下载</a>

本文转自匠心十年博客园博客,原文链接:http://www.cnblogs.com/gaochundong/archive/2013/06/06/entityframework_usage_with_unity.html,如需转载请自行联系原作者

继续阅读