aggregates

How do I represent Domain Aggregates in MVC pattern?

SHould I create a separate class for each object in an aggregate or should the objects be nested classes of a single aggregate class? ...

Domain Driven Design - Aggregate Roots

I'm struggling with aggregates and aggregate roots. I have a natural aggregate root which works for about 60% of the user requests. I.e. those requests naturally apply to the aggregate root. Within my aggregate I have another entity which can only exist as a member of the aggregate root. Users, however, will be told about this other ...

Linq - calculate multiple averages in one query

I'm trying to convert some SQL queries into Linq to avoid multiple trips to the database. The old SQL I'm trying to convert does: SELECT AVG(CAST(DATEDIFF(ms, A.CreatedDate, B.CompletedDate) AS decimal(15,4))), AVG(CAST(DATEDIFF(ms, B.CreatedDate, B.CompletedDate) AS decimal(15,4))) FROM dbo.A INNER JOIN dbo.B ON B.Par...

Getting Additional Data for a Domain Entity

I have a domain Aggregate, call it "Order" that contains a List of OrderLines. The Order keeps track of the sum of the Amount on the Order Lines. The customer has a running "credit" balance that they can order from that is calculated by summing the history of their database transactions. Once they use up all the money in the "pool" they ...

DDD: Aggregate Roots

Hello, I need help with finding my aggregate root and boundary. I have 3 Entities: Plan, PlannedRole and PlannedTraining. Each Plan can include many PlannedRoles and PlannedTrainings. Solution 1: At first I thought Plan is the aggregate root because PlannedRole and PlannedTraining do not make sense out of the context of a Plan. The...

Aggregate analog of row count component?

I'd like to have a way to get the sum of a field stored into a variable from inside a dataflow task. The rowcount transform does this, but I can't see how to use any other aggregate functions. Is scripting a transform component my best bet? ...

Django - Count a subset of related models - Need to annotate count of active Coupons for each Item

I have a Coupon model that has some fields to define if it is active, and a custom manager which returns only live coupons. Coupon has an FK to Item. In a query on Item, I'm trying to annotate the number of active coupons available. However, the Count aggregate seems to be counting all coupons, not just the active ones. # models.py cla...