domain-driven-design

Is it possible to implement MediatR in the Aggregates (Domain Layer) without dependency injection (DDD)?

给你一囗甜甜゛ 提交于 2020-01-02 10:22:19
问题 To prevent reinventing the wheel, I'd like to use MediatR in the Aggregates to publish domain events. (Un)Fortunately(?) MediatR works as a dependency that is injected into the classes, and not something that I can call statically. Therefore I'd end up creating a direct dependency on the library via the constructor. I don't remember where I read it (and if I read it right), that I should avoid non-business dependencies in the constructors of the Aggregates. Therefore, I shouldn't do something

Domain Driven Design Question on Services and Repositories

帅比萌擦擦* 提交于 2020-01-01 14:43:13
问题 I have two entities User and Course. A user can take several courses which makes the relationship one to many. But a single course can be taken by many students so it makes it many to many relationship. Now, I need to register a course for a user. My user entity has: public void AddCourse(Course course) { if (CoursesAlreadyAdded(course)) { AddBrokenRule(new BrokenRule() { PropertyName = course.ClassCode, Message = String.Format("Course with classCode = {0} already added", course.ClassCode) })

Can the domain model and repositories be in seperate dlls?

耗尽温柔 提交于 2020-01-01 12:07:18
问题 Can the domain model and the repositories be in separate dlls? In a 3 tier architecture I guess I would put the domain model in the business layer and the repositories in the data access layer. I get confused as it is my understanding that the domain model uses the repositories while the repositories should return objects from the domain model, which would cause a circular dependency. I must be misunderstanding one or more of the above concepts. Any clarification would be greatly appreciated

Accessing a web service from CQRS

余生颓废 提交于 2020-01-01 09:03:05
问题 Supposed I have a CQRS-based system and my domain needs some data from an external web service to make its decisions. How do I model this correctly? I can think of two options: The command handler runs the domain logic and the domain itself calls out to the web service. Once it gets a response, it attaches the appropriate events to the current aggregate and stores them. The domain basically "waits" for the web service to return. The command handler runs the domain logic and the domain

Accessing a web service from CQRS

末鹿安然 提交于 2020-01-01 09:02:10
问题 Supposed I have a CQRS-based system and my domain needs some data from an external web service to make its decisions. How do I model this correctly? I can think of two options: The command handler runs the domain logic and the domain itself calls out to the web service. Once it gets a response, it attaches the appropriate events to the current aggregate and stores them. The domain basically "waits" for the web service to return. The command handler runs the domain logic and the domain

DDD - Consistency of Entity Across Bounded Context & Different Schemas in Database

风流意气都作罢 提交于 2020-01-01 05:24:27
问题 I am implementing DDD with Entity Framework Code First. My Domain Model is persisted as it is without any mapping layer. I am following approach suggested during Tech-Ed by Julie Lerman. Each bounded context maps to different schema within same database. If same entity say, Customer appears across different bounded contexts how do we maintain consistency of data for Customer entity? 回答1: Only a single bounded context will be the system of record for your entity. If you cannot get away with

DDD: what's the use of the difference between entities and value objects?

你。 提交于 2020-01-01 05:20:14
问题 Entities and value objects are both domain objects. What's the use of knowing the distinction between the two in DDD? Eg does thinking about domain objects as being either an entity or value object foster a cleaner domain model? 回答1: Yes, it is very helpful to be able to tell the difference, particularly when you are designing and implementing your types. One of the main differences is when it comes to dealing with equality, since Entities should have quite different behavior than Value

How to work with inheritance on DDD

岁酱吖の 提交于 2020-01-01 04:53:21
问题 I am currently trying out DDD and reading Evans book. I have arrived at a model that has an aggregate whose root is Student. Now I need to have (or be able to distinguish) a RegisteredStudent and an EnrolledStudent (inherits RegisteredStudent). I don't know how to handle inheritance in DDD. Should the 2 inherited classes be inside the aggregate? If so, are they also considered aggregate roots since their identity is the same as the root (there are only added properties to them)? If not, how

NHibernate IQueryable collection as property of root

大憨熊 提交于 2020-01-01 04:15:05
问题 I have a root object that has a property that is a collection. For example: I have a Shelf object that has Books. // Now public class Shelf { public ICollection<Book> Books {get; set;} } // Want public class Shelf { public IQueryable<Book> Books {get;set;} } What I want to accomplish is to return a collection that is IQueryable so that I can run paging and filtering off of the collection directly from the the parent. var shelf = shelfRepository.Get(1); var filtered = from book in shelf.Books

One service for each entity?

不打扰是莪最后的温柔 提交于 2020-01-01 03:46:07
问题 Again - i'm confused about DDD things :) I have architeture (I'm still working on it) that in short hand looks like that: DataLayer: EntityDao -> Implementing domain layer interfaces (NHibernate) DomainLayer: EntityRepository -> Repository for each entity with injected Dao DomainObjects/Entitys -> Some logic UI ASP.Net MVC And I'm right now in that point where I feel to create and use some Service class. I have some questions with that: 1.Should I create at least one service for each entity