Repository pattern - how to correctly handle JOINs and complex queries?

后端 未结 1 917
孤街浪徒
孤街浪徒 2021-02-01 06:56

I have a problem with Repository pattern - how to perform JOIN operations between several repositories. In this project, we use MVC, EF, DDD. I\'m aware that this kind of questi

相关标签:
1条回答
  • 2021-02-01 07:24
    1. means leaking persistence into application - antipattern, spaghetti-code.
    2. how it differs from (1) exactly? Still the same issue.
    3. a bit closer...
    4. Use Query Object pattern. Encapsulate your complex query in a task-based object that resides alongside repositories. It can return DTOs optimized for view rather than domain objects.
    5. Relying heavily on QO will lead you to an architecture called CQRS - Command-Query Responsibility Segregation.

    One more thing. There is not 1:1 match for entity:repo. Only Aggregates should have a repository, not every single entity.

    0 讨论(0)
提交回复
热议问题