1

我一直在寫MVC應用使用的是我所謂的服務的存儲庫的UnitOfWork模式,它看起來像這樣:洋蔥體系結構是否與Service-Repository-UnitOfWork模式類似?

MVC Controllers --> Services --> Repositories --> EntityFramework

然後

Repositories/EntityFramework (constructs Domain Objects/POCO) --> Services --> Transform to ViewModels --> Controller --> Send the ViewModel/View to the client.

我使用IoC容器爲注入到各個組件的構造函數中的服務,存儲庫和UnitOfWork配置接口。

我的問題是,這完全類似於洋蔥建築嗎?

這是否有意義?

+2

什麼是洋蔥建築? – 2012-08-03 05:10:51

+1

也許你應該閱讀Jeffrey Pallermo的關於他的Onion Architecture的文章,以確定它是否匹配:http://jeffreypalermo.com/blog/the-onion-architecture-part-1/。 – Steven 2012-08-03 08:34:58

回答

3

不,它不是。這些是來自不同類別的模式。

洋蔥架構管理整個解決方案,與「多層」或「SOA」或「客戶端服務器」相同。

「服務層」,「Repository」,「UoW」代表實現模式,它們管理您應用程序內部的特定部分。