aggregateroot

Eager loading of lazy loaded entities in nHibernate using ActiveRecord

I'm working on a project that has a rich object model with various sets of aggregate roots. We're using the Castle stack (Monorail through to nHibernate with ActiveRecord). We have marked the aggregate roots as lazy [ActiveRecord(Lazy = true)] and have customized 'eager' routines on our Repository to eager fetch an object graph. We us...

NHibernate - drilling down from the aggregrate root

Given an aggregate root X, which has many Y, and Y which has many Z... How can I drill down through the associations and select only those X's whose Z's have a certain property value? IList Xs = Session.CreateCriteria(typeof(X)) .CreateAlias("Ys", "Y") .CreateAlias("Y.Zs", "Z") ...

Eager Loading aggregate roots with Entity Framework

I would like to create a more structured approach to loading the needed entity-tree: I need a serious amount of data, so I'm doing this using type-safe Includes (just a normal Include but with Lambda's) as shown here. As I said, I need a lot of data, basically a whole entity tree under 1 parent item. Now, I could do this doing somethi...

DDD: aggregate root question

Let's say i got 2 entities - Foo and Bar. Foo is an aggregate root and contains Bar. As far as i understand, it should look like this: public class Foo{ private readonly Bar Bar; } I want to provide functionality for users to choose Bars for Foos from a defined list (and change it). If repositories are supposed to be for aggreg...

DDD/NHibernate Use of Aggregate root and impact on web design - ex. Editing children of aggregate root

Hopefully, this fictitious example will illustrate my problem: Suppose you are writing a system which tracks complaints for a software product, as well as many other attributes about the product. In this case the SoftwareProduct is our aggregate root and Complaints are entities that only can exist as a child of the product. In other w...

What's an Aggregate Root?

I'm trying to get my head around how to properly use the repository pattern. The central concept of an Aggregate Root keeps coming up. When searching both the web and Stack Overflow for help with what an aggregate root is, I keep finding discussions about them and dead links to pages that are supposed to contain base definitions. In the...

Unit testing domain objects

We have a requirement to add an event reminder when a user enters their email address on an event page. Event is another domain object. Our initial thought was to create a Customer domain object and related CustomerService: public class CustomerService { public void AddEventReminder(string emailAddress, int eventId) { var cus...

How should the addition of an aggregate root to a repository be expressed?

Let's say we have an aggregate root entity of type Order that relates customers and order lines. When I think about an order entity it's more natural to conceptualize it as not being defined without an Id. An order without an Id seems to be better represented as an order request than an order. To add an order to a repository, I usuall...

Aggregate roots. How far does the rabbit hole go.

I'm trying to use the Repository pattern for my current project and i'm currently in the process of trying to model the domain and find the aggregate roots. I've read of the 'Cascading Delete' rule which states that if it doesn't make sense to delete a member when the root is deleted then it shouldn't be part of the root. I'll use a P...

Dealing with nested aggregates in DDD

I'm just getting started in DDD, and I'm having some trouble figuring out how to accommodate the relational nature of my data. I have what I believe would be considered my aggregate root, but the aggregate also has an aggregate of its own. Not wanting to violate the Law of Demeter, I'm wondering if I'm thinking about this wrong and am ...

DDD: Getting aggregate roots for other aggregates

I've been studying DDD for the past 2 weeks, and one of the things that really stuck out to me was how aggregate roots can contain other aggregate roots. Aggregate roots are retrieved from the repository, but if a root contains another root, does the repository have a reference to the other repository and asks it to build the subroot? ...

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...

ASP.NET MVC: what mechanic returns ViewModel objects?

As I understand it, Domain Models are classes that only describe the data (aggregate roots). They are POCOs and do not reference outside libraries (nothing special). View models on the other hand are classes that contain domain model objects as well as all the interface specific objects like SelectList. A ViewModel includes using Sy...

DDD: Persisting aggregates

Hello, Let's consider the typical Order and OrderItem example. Assuming that OrderItem is part of the Order Aggregate, it an only be added via Order. So, to add a new OrderItem to an Order, we have to load the entire Aggregate via Repository, add a new item to the Order object and persist the entire Aggregate again. This seems to hav...

NHibernate : Root collection with an root object

Hi, I want to track a list of root objects which are not contained by any element. I want the following pseudo code to work: using (session1 = [...]) { IList<FavoriteItem>list = session1.Linq<FavoriteItem>().ToList(); } list.Add(item1); list.Add(item2); list.Remove(item3); list.Remove(item4); var item5 = list.First(i => i.Name = "Fo...

Traversing Aggregates

Doing a bit of reading around domain driven design and it seems that you're supposed to access all entities within an aggregate by traversal from the aggregate root. However, at the same time you should really try and encapsulate your data so that the properties/fields are protected or private. Therefore my question is: If the fields a...

DDD: Question about Aggregate boundaries

Hi guys, I have a complicated scenario in which two aggregate boundaries sort of contradict each other. I have 2 Entities: Request and Mission. User creates Requests and later on he can create Missions and assign existing Requests to a Mission. Requests and Missions can be created independently. In other words, I don't need to have...

ASP.NET MVC/Entity Framework: Accessing aggregate objects through the aggregate root repository

I'm in the process of building my first web application using ASP.NET MVC 2 and the Entity Framework. I am using the repository pattern. From information I have gathered on Stack Overflow and other websites it appears that the consensus is to have one one controller per domain model object and one repository per aggregate root object. T...

DDD modeling, interaction between aggregate roots

Marked my aggregate roots with 1;2;3. Looks quite nice - almost like grapes. Thing I dislike is an entity that's marked with red arrow. Let's imagine that: AR #1 is company AR #2 is office AR #3 is employee Entity marked with red arrow is named Country Company sets the rules from which countries it hires employees (on hiring...

How to model Aggregates using Entity Framework?

While I have been dealing with domain-driven design (DDD) for quite some time now, I'm relatively new to Entity Framework (EF), and one question that came to my mind when using the Entity Framework Designer in Visual Studio was how Aggregates should be represented/modeled in EF. Following DDD best practices, Entities should only referen...