2

I'm looking into converting part of an large existing VB6 system, into .net. I'm trying to use domain driven design, but I'm having a hard time getting my head around some things.

One thing that I'm completely stumped on is how I should handle complex find statements. For example, we currently have a screen that displays a list of saved documents, that the user can select and print off, email, edit or delete. I have a SavedDocument object that does the trick for all the actions, but it only has the properties relevant to it, and I need to display the client name that the document is for and their email address if they have one. I also need to show the policy reference that this document may have come from. The Client and Policy are linked to the SavedDocument but are their own aggregate roots, so are not loaded at the same time the SavedDocuments are.

The user is also allowed to specify several filters to reduce the list down. These to can be from properties that are stored on the SavedDocument or the Client and Policy.

I'm not sure how to handle this from a Domain driven design point of view.

  1. Do I have a function on a repository that takes the filters and returns me a list of SavedDocuments, that I then have to turn into a different object or DTO, and fill with the additional client and policy information? That seem a little slow as I have to load all the details using multiple calls.
  2. Do I have a function on a repository that takes the filters and returns me a list of SavedDocumentsForList objects that contain just the information I want? This seems the quickest but doesn't feel like I'm using DDD.
  3. Do I load everything from their objects and do all the filtering and column selection in a service? This seems the slowest, but also appears to be very domain orientated.

I'm just really confused how to handle these situations, and I've not really seeing any other people asking questions about it, which masks me feel that I'm missing something.

4

1 に答える 1

2

DDD では、いくつかの方法でクエリを処理できます。場合によっては、ドメイン エンティティ自体を使用してクエリを提供できます。このアプローチは、クエリで複数の集計のプロジェクションが必要な場合のようなシナリオでは扱いにくくなる可能性があります。この場合、それぞれのクエリ用に明示的に設計されたオブジェクト (事実上 DTO) を使用する方が簡単です。これらの DTO は読み取り専用になり、何の動作もありません。これは、読み取りモデル パターンと呼ばれます。

于 2013-01-04T16:57:39.470 に答える