cqrs

Who is responsible for entity's mutation when domain event is raised? DDD

和自甴很熟 提交于 2019-12-09 03:18:43
问题 I've been learning about CQRS / ES . Looking at small example projects I often see events mutating the entity state . For instance If we look at the Order aggregate root : public class Order : AggregateRoot { private void Apply(OrderLineAddedEvent @event) { var existingLine = this.OrderLines.FirstOrDefault( i => i.ProductId == @event.ProductId); if(existingLine != null) { existingLine.AddToQuantity(@event.Quantity); return; } this.OrderLines.Add(new OrderLine(@event.ProductId, @event

Using ViewModels instead DTOs as the result of a CQRS query

戏子无情 提交于 2019-12-08 19:16:31
问题 Reading a SO question, I realized that my Read services could provide some smarter object like ViewModels instead plain DTOs. This makes me reconsider what information should be provided by the objects returned by the Read Services Before, using just DTOs, my Read Service just made flat view mapping of a database query into hash like structure with minimum normalization and no behavior. However I tend to think of a ViewModel as something "smarter" that can have generated information not

How to handle transaction in event driven architecture?

心已入冬 提交于 2019-12-08 13:47:31
I'm currently playing with DDD & CQRS, and I moved forward a legacy application. Let's say I have an Article entity, on which I can cast votes. When a Vote is casted on an Article, I want to increment or decrement a counter accordingly to the value of the vote. This counter is part of my Query model and thus I don't think it fits the Domain Model, for such reasons, I decided to write a CastArticleVoteService in which I put the business logic about a vote, and I dispatch an Event to be handle by a custom Event Handler which in turns update the counter in a database. First of all, I was

where should put input validation in Domain Driven Design?

不问归期 提交于 2019-12-08 11:59:02
问题 I was wondering where exactly we should put input validations(imagine an API call send input to apply free times of a user). Is it right to inject validation class in service Layer and call validate method inside service? or it's better to put it in the infrastructure layer or even in Domain model? I just wanted to see a sample code that's implement validation of input for an API in Domain-driven design approach? what if I use CQRS architecture? 回答1: I use in my DDD/CQRS project following

Dynamically creating operations and services in ServiceStack

柔情痞子 提交于 2019-12-08 04:37:33
问题 I'm working on a ServiceStack project that requires me to gather a list of commands, of which I have over 200, and create a operation and service for each of them. Essentially I am making a Commanding API which will allow users to send commands without using the UI (exposing my commands). A simplistic example of what I am trying to do: (Application Start) Gather all commands (with some exemptions) for each command make an operation and service for that command map the commands attributes to

EventStore + RavenDB, not deserializing correct

家住魔仙堡 提交于 2019-12-08 04:16:32
问题 Trying out JOliver CommonDoman/EventStore 3.0 with RavenDB, where it works fine to store events, but when trying to load an aggregate root with IRepository.GetById() there is an issue in deserialization. Giving the error message "Unable to cast object of type 'Raven.Abstractions.Linq.DynamicList' to type 'System.Collections.Generic.List`1[EventStore.EventMessage]'." at DocumentObjectSerializer.cs, public T Deserialize<T>(object document) { Logger.Verbose(Messages.DeserializingStream, typeof(T

ViewModel location when doing CQRS

前提是你 提交于 2019-12-08 03:13:50
问题 Suppose you have a layered project divided into the Presentation Layer, the Business Layer and the Data Access Layer. If you were using CQRS, you would be doing queries directly from the Data Access Layer into the Presentation Layer and bypassing the Business Layer. In that case, if you are using ViewModels in your presentation layer, then your Data Access Layer would need reference to the Presentation Layer to return data in terms of the ViewModels in the presentation layer. Wouldn't that be

How to use J Oliver's EventStore library?

↘锁芯ラ 提交于 2019-12-07 22:32:47
问题 I've been looking into Event Sourcing for a new project with J Oliver's EventStore and mongo as the persistence layer but have come across a few questions: Previous to trying event sourcing my domain persisted to a db and I've been using Udi's domain events pattern which has worked really well for me with NHibernate managing the unit of work. However I've ended up with one unit of work that can affect more than one aggregate eg. I "checkout" my shopping basket aggregate which raises an event

ViewModels, CQRS and Entities

一笑奈何 提交于 2019-12-07 20:54:33
问题 I am trying to understand how to probably make use of a view model, a command and the database entity At the moment I think there is a lot of manual mapping between this, and I am unsure if I should use a tool like AutoMapper to map ViewModel <-> Command <-> Entity when there is a lot of properties (like 10-15). Take this example (written quickly in notepad, may not compile - in my real applicaiton I use dependency injection and IoC): public class Student { public int Id { get; set; } public

Occasionally connected CQRS systems - Client and Server Commands - Task based screens

杀马特。学长 韩版系。学妹 提交于 2019-12-07 20:01:33
问题 Premise: It is recommended that in CQRS+DDD+ES style applications use task based screens, these screens guide the user and capture intent. These task screens can also be referred to as Inductive User Interface . Some examples of UI design guidelines that can help you create mondern, user-friendly apps: Microsoft Inductive User Interface Guidelines and, Index of UX guidelines The way I understand it, the tasks , generally speaking, should line up with Commands or Functions waiting on the