Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Question] why OrderQueries implementation not in the Infrastructure? #1628

Closed
jzhouw opened this issue Mar 11, 2021 · 3 comments
Closed

[Question] why OrderQueries implementation not in the Infrastructure? #1628

jzhouw opened this issue Mar 11, 2021 · 3 comments
Labels

Comments

@jzhouw
Copy link

jzhouw commented Mar 11, 2021

OrderRepository, implementation of IOrderRepository used by command is located in Infrastructure layer

But OrderQueries , the implementation of OrderQuery used by query shouldn't be in the Infrastructure layer too?

@sughosneo
Copy link
Contributor

Hi @jzhouw, thank you for reaching out.

Martin Fowler describes a repository as follows:

A repository performs the tasks of an intermediary between the domain model layers and data mapping, acting in a similar way to a set of domain objects in memory. Client objects declaratively build queries and send them to the repositories for answers. Conceptually, a repository encapsulates a set of objects stored in the database and operations that can be performed on them, providing a way that is closer to the persistence layer. Repositories, also, support the purpose of separating, clearly and in one direction, the dependency between the work domain and the data allocation or mapping.

In that aspect if you would notice repositories need stay closer with the infrastructure layer where as query layer should be residing with application where actual data mapping happens.

For more details you can refer Design the infrastructure persistence layer

Hope this helps !

@jzhouw
Copy link
Author

jzhouw commented Mar 11, 2021

hi @sughosneo thanks. I got above question when seeing Ordering.API package depends on Dapper (infrastructure) directly. I got it is because closer to the data mapping and uses dto/viewmodel as query's output. So is this an exception when introduce direct dependency to infrastructure in presentation/application layer?

If so, in application layer to call an external web api, should I define the IThirdParyCall in this layer and implement it in infrastructure layer, or just implement in the same application layer? what would you advice? thanks

@jzhouw
Copy link
Author

jzhouw commented Mar 12, 2021

found this old post very informative. thanks
#592

@jzhouw jzhouw closed this as completed Mar 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants