2015-12-30 42 views
2

目前我正在學習領域驅動設計。根據我的理解,我創建了一個樣例應用程序,在國家進行一些操作。Get方法如何適合領域驅動設計

我已經裝箱名爲「MyTest.Country」一個類庫,它包含了所有命令 -

--MyTest.Country (ProjectName) 
    -- Commands (Folder) 
     --CreateCountry (: ICommand) 
     --DeleteCountry (: ICommand) 

我有一個名爲「MyTest.CountryClient」另一個類庫,使用EF數據庫交互。

--MyTest.CountryClient (Project) 
    --CountryClass (ClassFile) 
    --CreateCountry (Method) 
    --DeleteCountry (Method) 
    --GetAllCountryList (Method) 

另一個名爲「MyTest.CountryServices」的服務的類庫包含處理程序。

--MyTest.CountryServices (Project) 
     --CountryHandler : IHandleMessages<CreateCountry> 
         : IHandleMessages<DeleteCountry> 

我有一個Web API,它發送命令「MyTest.CountryServices」使用NServiceBus創建或刪除的國家。該消息由CountryHandler處理,然後從「MyTestCountryClient」調用相應的方法。

我知道國家是一個實體,不能被定義爲一個域。但是,我只是試圖實施DDD。

我的問題在這裏 -

  1. 我在這裏遵循正確的原則DDD?

  2. 如果我想得到所有的國家名單,我應該直接調用MyTest.CountryClient嗎?或者我需要先調用服務,即使對於獲取操作?

+0

看看Udi在這方面的話題:https://skillsmatter.com/skillscasts/1806-talk-from-udi-dahan –

+1

我同意fabriciorissetto,你錯過了存儲庫模式。 – inf3rno

回答

4

在你的情況CountryClient似乎是您Repository。如果是這樣,是的,你可以直接打電話給它。

我建議你開始進入DDD building blocks。並且不要深入開始消息和命令。