Query models vs entity models #965
renetitulaer
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Let's take the example Order with a Customer.
Assume there is an Order and Customer aggregate.
But they are in the same SQL database and there is a FK from Order to Customer.
Order entity has a reference to customer by ID (no navigation property to customer because it should reference another entity by ID according to DDD).
This works fine when creating new orders. (In CQRS terms -> commands).
From query point of view I want to query the customer details (name, email, ...) for a set of orders (CQRS -> queries).
So I create a QueryModel where the Order has a Customer reference. To get this populated I need another Entity Framework Context with another EF Configuration for Order (which includes the FK relation to get the customers populated).
Now I want to use Ardalis specifications. Ardalis specifications are based on IAggregate and IRepository. But for the query site, the naming is conceptual not right. I want to create a specification for my OrderQueryModel but this is not an aggregate. On the domain model site it's an aggregate but on the query model site it's not. So I completely separated the query model and entity model but it looks like Ardalis specification is too much coupled to the DDD aggregate concept which is what I don't want on the Query site.
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions