I could create ViewModels in my Repository layer?

78 views
Skip to first unread message

Tiago Santos

unread,
Dec 14, 2017, 1:26:22 PM12/14/17
to DDD/CQRS
Geez, you got me a doubt. If in CQRS my Query Stack talks directly to the Data Layer and I use a Repository Pattern, in the rule, we must bring from the database only the data that I will actually show in the UI. So, could I make the query methods from my Repository return ViewModels? What if I could create these ViewModels in my Repository layer? Since if I create these ViewModels in my Application Layer and my Application Layer refers to the Data Layer, it will not be possible for me to return those ViewModels because they will be created in my Application Layer, which is what generally developers do.

Peter Hageus

unread,
Dec 15, 2017, 9:25:01 AM12/15/17
to ddd...@googlegroups.com
One of the major benefits of CQRS is being able to bypass all the layers on the view/query side… Why do you need to layer and abstract a simple databasequery?

/Peter

On 14 Dec 2017, at 19:26, Tiago Santos <taigo...@gmail.com> wrote:

Geez, you got me a doubt. If in CQRS my Query Stack talks directly to the Data Layer and I use a Repository Pattern, in the rule, we must bring from the database only the data that I will actually show in the UI. So, could I make the query methods from my Repository return ViewModels? What if I could create these ViewModels in my Repository layer? Since if I create these ViewModels in my Application Layer and my Application Layer refers to the Data Layer, it will not be possible for me to return those ViewModels because they will be created in my Application Layer, which is what generally developers do.

--
You received this message because you are subscribed to the Google Groups "DDD/CQRS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dddcqrs+u...@googlegroups.com.
Visit this group at https://groups.google.com/group/dddcqrs.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages