JasperFx / wolverine

Supercharged .NET server side development!
https://wolverinefx.net
MIT License
1.21k stars 131 forks source link

Question: How to load nested entities in Sagas? #625

Closed mbinot closed 10 months ago

mbinot commented 10 months ago

Hi Jeremy,

first of all I would like to thank you for this powerful and promising framework.

I am currently trying to implement a Saga that includes a collection of a nested entity. WolverineFx is set up to use Entity Framework for persistance.

When the create-command is send to Wovlerine the Saga seems to be created properly and I can find the entity itself and all nested entries in the corresponding database tables afterwards (yay!). When a following command is handled wihtin the Saga, the main properties are set, but the collection of the nested entity is null. What do I need to do to make Wolverive include the collection when loading the Saga from the database?

jeremydmiller commented 10 months ago

Unfortunately, the temporary answer is you can't. With EF Core mechanics, you'd have to do the explicit Include() business. Wolverine is going to need some extension here to handle this kind of thing.

Admittedly, we're working a lot more with Marten, and sometimes you'll see where the Wolverine + Marten integration is considerably more mature or just that wolverine is a little optimized for Marten rather than EF Core.

Another option I'd like to do is to have a lightweight JSON serialized model ala Marten itself for both Sql Server and PostgreSQL w/o Marten.

jeremydmiller commented 10 months ago

Open a new issue about improving the Saga support with EF Core if you want -- but I think I'd like to deprecate the EF Core saga storage in favor of a lightweight, direct Sql Server or PostgreSQL JSON storage to avoid these problems. I'm closing this as there's nothing immediately actionable and issues are for the backlog.