aggregateroot

Aggregate root with Entity Framework using Domain Driven Design

倖福魔咒の 提交于 2019-12-04 21:48:07
问题 I am building an application using Domain Driven Design that is using Entity Framework. My goal is to allow my domain models (that get persisted with EF) contain some logic within them. Out of the box, entity-framework is pretty nonrestrictive as to how entities get added to the graph and then persisted. Take for example, my domain as POCO (without logic): public class Organization { private ICollection<Person> _people = new List<Person>(); public int ID { get; set; } public string

Aggregate Root support in Entity Framework

女生的网名这么多〃 提交于 2019-12-04 18:15:41
问题 How can we tell Entity Framework about Aggregates? when saving an aggregate, save entities within the aggregate when deleting an aggregate, delete entities within the aggregate raise a concurrency error when two different users attempt to modify two different entities within the same aggreate when loading an aggregate, provide a consistent point-in-time view of the aggregate even if there is some time delay before we access all entities within the aggregate (Entity Framework 4.3.1 Code First)

DDD modeling, interaction between aggregate roots

非 Y 不嫁゛ 提交于 2019-12-03 13:42:23
问题 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, company.Countries.Contains(employee.Country) must be true) I somehow see this quite unimportant part of domain (maybe it does not sound like that in this example one),

How should I enforce relationships and constraints between aggregate roots?

戏子无情 提交于 2019-12-03 07:32:46
问题 I have a couple questions regarding the relationship between references between two aggregate roots in a DDD model. Refer to the typical Customer/Order model diagrammed below. First, should references between the actual object implementation of aggregates always be done through ID values and not object references? For example if I want details on the customer of an Order I would need to take the CustomerId and pass it to a ICustomerRepository to get a Customer rather then setting up the Order

Dealing with nested aggregates in DDD

允我心安 提交于 2019-12-03 05:09:14
问题 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 hoping that some DDD expert can offer some insight. My aggregate root is my Account object, which has an aggregate of numerous AccountElement entities, which

DDD - How to design associations between different bounded contexts

醉酒当歌 提交于 2019-12-02 21:08:24
I have setup a domain project which is being populated with an ORM. The domain contains of different aggregates each with its own root object. My question is how properties that cross the aggregate boundries should be treated? Should these properties simply ignore the boundries so that a domain object in bounded context A has a reference to an object in context B? Or, should there be no direct link from context A to B and does the object in context A have an "int ContextBId" property that can be used to get the domain object from B through the B aggregate root? Or ... An example: Context A =

Searching for a Child across Aggregate Roots

只谈情不闲聊 提交于 2019-12-01 10:53:06
The repository pattern suggest that you can only pull aggregate roots. But how would you retrieve a single child using only it's uniqiue identity(Child.ID) if you do not know it's parent(root)? class Parent { public int ID { get; set; } IEnumerable<Child> Children { get; private set; } } class Child { public int ID { get; private set; } public virtual Parent Parent { get; private set; } // Navigational model } My application is stateless (web), for simplicity, the request only contains the ID of the child. I am thinking three approaches: Call all the parents then ask them politely who owns

When to update audit fields? DDD

折月煮酒 提交于 2019-12-01 04:43:27
I have a Meeting Object: Meeting{id, name, time, CreatedBy, UpdatedBy} and a MeetingAssignee{id, MeetingID, EmployeeId, CreatedBy, UpdatedBy) Meeting, as Aggregate root, has a method AssignEmployee. I was about to pass in the current user to the Meeting object as I call AssignEmployee, so that it can update its audit fields accordingly. But this doesn't seem right - is it? Obviously I can keep the audit fields public and change them later - perhaps at service level? What is everyone's else preferred method for updating these fields? Please note: We are not using Nhibernate, but a custom ORM

When to update audit fields? DDD

强颜欢笑 提交于 2019-12-01 02:41:18
问题 I have a Meeting Object: Meeting{id, name, time, CreatedBy, UpdatedBy} and a MeetingAssignee{id, MeetingID, EmployeeId, CreatedBy, UpdatedBy) Meeting, as Aggregate root, has a method AssignEmployee. I was about to pass in the current user to the Meeting object as I call AssignEmployee, so that it can update its audit fields accordingly. But this doesn't seem right - is it? Obviously I can keep the audit fields public and change them later - perhaps at service level? What is everyone's else

Update an entity inside an aggregate

你。 提交于 2019-11-30 04:15:31
问题 I was reading a similar question on SO: How update an entity inside Aggregate, but I'm still not sure how a user interface should interact with entities inside an aggregate. Let's say I have a User , with a bunch of Address es. User is the aggregate root, while Address only exists within the aggregate. On a web inteface, a user can edit his addresses. Basically, what happens is: The user sees a list of addresses on its web interface He clicks on an address, and gets redirected to this page: