3

So after much reading I've now come to the realization that complex reporting functions do not belong in your typical Repository and that there needs to be some kind of dedicated "Finder" which returns read only objects to be used in reporting.

What I'm unclear on is where the "Finder" classes, as well as their associated ReadModel classes are supposed to go inside my project? Are the finders like repositories in that you have an interface for the finder inside the infrastructure assembly along with concrete Readmodels?

Where do these classes belong?

4

1 回答 1

3

我通常有一个逻辑查询“层”。合乎逻辑,因为我并不总是需要将它分成自己的程序集(从 .Net/C# 的角度来看)。它不应该在您的域中,因为该域不应该查询恕我直言。域涉及聚合、实体、值对象等。它需要的任何其他内容都需要输入到域对象中。查询位可能更多地在应用程序服务边缘发挥作用。

然后我最终得到的是我的存储库仅返回所需的完整聚合/实体以及IQuery在读取端实现的单独接口。通常我把它放在一个DataAccess程序集中。例如:

public interface IUserQuery
{
    bool ContainsEMail(string emailAddress);
    int NumberOfAdminisitrators();
    DataRow Profile(Guid id);
    DataTable FriendRequests(Guid id);
    SomeReadModel ForSomethingThatContainsSayAList(DateTime date);
}

您会注意到,如果可以的话,我会使用简单类型,而技术特定的数据访问对象(例如DataRow, DataTable, never DataSet :) --- 虽然DataSet 可以用于复合数据,但它有点麻烦。

我尝试将特定的读取模型 (DTO) 保持在最低限度,但有时在处理复合数据时可能需要它们。

于 2013-06-17T06:45:08.597 回答