Home > Net >  How to query automatonymous sagas instances to check if other instances have the same value?
How to query automatonymous sagas instances to check if other instances have the same value?

Time:10-12

Lets assume I have an order state machine and instance, I also have the repository to save the info to my postgres database.

An update event arrives to update the delivery date in my order, but I want to check that no other instance of the other orders have the same delivery date before updating (because I only have 1 delivery man).

The solution I have so far is just creating a custom Activity, but want to know if this is the correct approach

CodePudding user response:

If you're using Entity Framework Core, you can add your DbContext (which includes the saga class map) as a dependency on your activity and query the table to see if there is another matching date and handle the outcome appropriately. The entire operation will be in a transaction, as MassTransit starts a transaction before loading the saga instance.

  • Related