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 7405069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:20:51+00:00 2026-05-29T05:20:51+00:00

I am currently using J Oliver’s EventStore and I want to know how I

  • 0

I am currently using J Oliver’s EventStore and I want to know how I can check if an aggregate exists when I do my call (GetById(Guid id))?

Following how CQRS works, should I be querying the read database or should I somehow find out if there is a corresponding aggregate in the EventStore?

  • 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-05-29T05:20:51+00:00Added an answer on May 29, 2026 at 5:20 am

    The way the EventStore works at the moment, you will create a new Stream (Aggregate root) if the stream is not found.

    Check this line:
    https://github.com/joliver/CommonDomain/blob/master/src/proj/CommonDomain.Persistence.EventStore/EventStoreRepository.cs#L53

    It calls this method on the Store:
    https://github.com/joliver/EventStore/blob/master/src/proj/EventStore.Core/OptimisticEventStore.cs#L45

    Which calls this constructor:
    https://github.com/joliver/EventStore/blob/master/src/proj/EventStore.Core/OptimisticEventStream.cs#L27

    The effect is that it will either populate the Stream using Commits that it found in the persistence, or if none are found it will do nothing and return the new Stream.

    However, you shouldn’t have to ask yourself this question. A Command should be validated before you send it. Use your read models to validate the command before you send it.

    Also, the Command together with Aggregate root state should be enough information to perform your decision in the domain. This basically means that you have to be certain of the domain state before you send your commands in order to avoid exceptions in the domain. And you can use the the read model for that.

    Update as a response to Mauros comment:

    You are having a concurrency issue. You might be able to solve it by using the method used in occasionally connected systems which is merging. What you can do is to store the Stream revision in the read model so that you know which revision of the AR you have acted upon. Then when the command is handled you know if you were acting upon an old state of the AR.

    If the AR revision is higher than than the one the command brings you can either discard the command as a failure (pessimistic concurrency), or you can try to merge the changes.

    This can be done by looking at the events produced from the revision in the command up until the current state. Then invoke the behavior the command was supposed to do and look at the events created by that behavior and compare the two event collections. If there aren’t any conflicting events, you can commit the newly created events to the store. If there are conflicts, you can throw a concurrency exception.

    I think that is your best bet to solve this type of concurrency issues.

    Search for Event Merging for more info.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're currently using the following for creating US dollar values in our web application:
Currently using: @^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$ How can i make http:// not compulsory but if it does
Im currently using base64_encode for some $_GET params that i don't want regular user
I am currently using the following code to get an UIImage from an ALAsset
Im currently using a script (that is working) where I can apply a certain
Currently using: https://github.com/felixge/node-mysql I have the following code: var connection = mysql.createConnection({ host :
Im currently using Classic ASP and developing my website with it. I want to
Currently using the following to make sure my website always is using www. How
Im currently using a method that looks like the following code to add script
I currently using jquery mobile and want to achieve the top navigation as youtube

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.