天天看點

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,如需轉載請自行聯系原作者

繼續閱讀