Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7806329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:29:59+00:00 2026-06-02T02:29:59+00:00

According to Fowler ( here ), a repository mediates between the domain and data

  • 0

According to Fowler (here), a repository “mediates between the domain and data mapping layers, acting like an in-memory domain object collection.” So, for example, in my Courier Service application, when a new run is submitted, my application service creates a new Run aggregate root object, populates it with values from the request then adds it to the RunRepository before calling the Unit of Work to save the changes to the database. When a user wants to view the list of current runs, I query the same repository and return a denormalized DTO representing the information.

However, when looking at CQRS, the query would not hit the same repository. Instead, it would perhaps go directly against the data store and always be denormalized. And my command side would evolve to a NewRunCommand and Handler that would create and populate a NewRun domain object then persist the information to the data store.

So the first question is where do repositories fit into the CQRS model if we aren’t maintaining an in-memory collection (cache, if you will) of domain objects?

Consider the case where the information submitted to my application service contains nothing but a series of ID values that the service must resolve in order to build the domain object. For example, the request contains the ID # of the courier assigned to the run. The service must lookup the actual Courier object based on the ID value and assign the object to the NewRun using the AssignCourier method (which validates the courier and performs other business logic).

The other question is, given the separation for queries and potential absence of repositories, how does the application service perform the lookup to find the Courier domain object?

UPDATE

Based on some additional reading and thought after Dennis’ comment, I’ll rephrase my questions.

It appears to me that CQRS encourages repositories that are merely facades over the data access and data storage mechanisms. They give the “appearance” of a collection (like Fowler describes) but are not managing the entities in-memory (as Dennis pointed out). This means that every operation on the repository is pass-through, yes?

How does a Unit of Work fit into this approach? Typically a UoW is used to commit changes made to a repository (right?) but if the repository isn’t maintaining the entities in-memory, then what role does a UoW have?

With regards to a ‘write’ operation, would the command handler have a reference to the same repository, a different repository or perhaps a UoW instead of a repository?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:30:00+00:00Added an answer on June 2, 2026 at 2:30 am

    I’ve read about CQRS systems that maintain a simple key value store on the command side to represent an application’s state, and others that merely correlate messages (using some sort of saga) and utilise the query store to represent an applications state instead. Either way there’ll no doubt be a persistence technology involved with these approaches, but the repository pattern in these cases would be an unnecessary abstraction over the top of it.

    My experience with CQRS has only ever been with event sourcing though, where we’ve replayed past events to rebuild aggregates that encapsulate and enforce business logic and invariants. In this case the repository pattern is a familiar abstraction that can provide a simpler way of retrieving any of these aggregates.

    With regards to the query side I’d recommend getting as close to the data store as possible, by this I mean avoid any repositories, services or facades etc. between your UI (whatever that may be) and your data store.

    It might help to see an example of these approaches in use. Maybe take a look at the following projects:

    • https://github.com/gregoryyoung/m-r/tree/master/SimpleCQRS
    • https://github.com/MarkNijhof/Fohjin
    • https://github.com/elliotritchie/NES
    • https://github.com/ToJans/Scritchy
    • http://ncqrs.org

    In the case of NES the repository merely provides a familiar interface for adding and reading aggregates directly to and from the unit of work.

    Some more links that might help:

    • CQRS Examples and Screencasts
    • Event Sourcing Resources
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to this definition , Fowler's concept of Anemic Domain Model is: a software
According to here , the C compiler will pad out values when writing a
According to php manual nor php://input neither $HTTP_RAW_POST_DATA work with multipart/form-data POST-requests. php://input allows
According Martin Fowler's Unit of Work description: Maintains a list of objects that are
According to the dataset specification , how is element.dataset meant to delete data attributes?
According To reflector , ExpandoObject Does implemenet IDictionary<string, object> How ever I have this
According to Martin Fowler Something can be public but that does not mean you
According to my class notes, you can allocate an array in C++ like int
According to the documentation i would like to overwrite predefined formats using this settings:
According to this article Silverlight 2 Beta 2 supports the DataContractJsonSerializer object. But, when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.