WCF消息和数据合同,DTO,域模型和共享程序集

Ray*_*ond 5 wcf soa domain-driven-design datacontract dto

我有一个调用我的WCF业务服务层的Web客户端,后者又调用外部WCF服务来获取实际数据.起初,我以为我会使用的DTO,并在不同的层独立商业实体......但我发现,倡导的DTO的简单的例子,是,好了,琐碎.我看到太多的重复代码并没有多少好处.

考虑我的域名:

示例域我有一个单独的UI屏幕(Asp.net MVC View),显示患者的药物清单,不良反应(药物之间)以及患者可能患有的任何临床情况(如抑郁或高血压).我的域名模型从顶层开始:

   MedicationRecord
      List<MedicationProfile> MedicationProfiles
      List<AdverseReactions> Reactions
      List<ClinicalConditions> ClinicalConditions

   MedicationProfile is itself a complex object
      string Name
      decimal Dosage
      Practitioner prescriber 

   Practioner is itself a complex object
      string FirstName
      string LastName
      PractionerType PractionerType
      PractionerId Id
      Address Address    

      etc.
Run Code Online (Sandbox Code Playgroud)

此外,在进行WCF请求时,我们有一个请求/响应对象,例如

   MedicationRecordResponse
      MedicationRecord MedicationRecord
      List<ClientMessage> Messages
      QueryStatus Status

   and again, these other objects are complex objects
   (and further, complicates matter is that they exist in a different, common shared namespace)
Run Code Online (Sandbox Code Playgroud)

在这一点上,我倾向于MedicationRecordResponse 我的DTO.但在纯DataContracts和DTO以及设计分离方面,我想这样做吗?

   MedicationRecordResponseDto
      MedicationRecordDto
      List<ClientMessageDto> 
      QueryStatusDto

   and that would mean I then need to do
      MedicationProfileDto
      PractitionerDto
      PractitionerTypeDto
      AddressDto
   etc.
Run Code Online (Sandbox Code Playgroud)

因为我已经在屏幕上显示了几乎所有信息,所以我有效地为每个域对象创建了1个DTO.

我的问题是 - 你会怎么做?你会继续创建所有这些DTO吗?或者您只是在一个单独的程序集中共享您的域模型?

以下是其他似乎相关的问题的解读:

  1. WCF合同知道域名
  2. SOA中转换层的替代方案:WCF
  3. SOA问题:公开实体