domain-driven-design

Implementation example for Repository pattern with Linq to Sql and C#

﹥>﹥吖頭↗ 提交于 2019-12-18 02:42:44
问题 I am looking for a Repository pattern implementation example/resource that follows domain driven design principles for my ASP.net MVC application. Does anyone have a good example or learning resource that can be shared? 回答1: It's not an uncontroversial implementation, but Rob Conery's web storefront project has implemented repository via Linq to Sql in C#. http://blog.wekeroad.com/ Source is available. He's not quite doing strict DDD, but his TDD is generally sending him out in that direction

DDD, value objects and ORM

Deadly 提交于 2019-12-18 00:42:53
问题 Value objects do not have identity. ORM needs identity to update the database. How to trick ORM? (Marking Id for value object as internal won't work because ORM lives in a different assembly and moving it to the same assembly is not acceptable). Thanks in advance. 回答1: As far as my understanding of DDD goes value objects are just a way to partition your entities. If a value object should be stored with an ID in the database it's not a value object. Example: The domain model looks like this (C

Consuming REST Web Service in .NET MVC 3

你说的曾经没有我的故事 提交于 2019-12-17 23:13:25
问题 I am working on a .NET 4 MVC 3 application. I'm trying to follow a domain driven design paradigm. Right now, my application is broken into two pieces, a domain and my MVC code for the web. I'd like some help in determining where in this structure I should consume a RESTful web service. This specific project uses a RESTful web service to retrieve and persist data. In my domain, I have two entities "Customer" and "User" which pair up with web services of the same name. e.g. URL/Customer and URL

Generic repository to update an entire aggregate

血红的双手。 提交于 2019-12-17 22:51:37
问题 I am using the repository pattern to provide access to and saving of my aggregates. The problem is the updating of aggregates which consist of a relationship of entities. For example, take the Order and OrderItem relationship. The aggregate root is Order which manages its own OrderItem collection. An OrderRepository would thus be responsible for updating the whole aggregate (there would be no OrderItemRepository ). Data persistence is handled using Entity Framework 6. Update repository method

MVVM: Modified model, how to correctly update ViewModel and View?

你离开我真会死。 提交于 2019-12-17 21:53:23
问题 Case Say I have a Person class, a PersonViewModel and a PersonView . Updating properties from PersonView to the Person model is simple enough. PersonViewModel contains a Person object and has public properties the PersonView binds to in order to update the Person model. However. Imagine the Person model can get updated by Service . Now the property change needs to be communicated to the PersonViewModel and then to the PersonView . This is how I would fix it: For each property on the Person

DDD and MVC: Difference between 'Model' and 'Entity'

心已入冬 提交于 2019-12-17 21:27:01
问题 I'm seriously confused about the concept of the 'Model' in MVC. Most frameworks that exist today put the Model between the Controller and the database, and the Model almost acts like a database abstraction layer. The concept of 'Fat Model Skinny Controller' is lost as the Controller starts doing more and more logic. In DDD, there is also the concept of a Domain Entity, which has a unique identity to it. As I understand it, a user is a good example of an Entity (unique userid, for instance).

How to share validation between Forms and Value Objects in Domain Driven Design?

自闭症网瘾萝莉.ら 提交于 2019-12-17 20:12:39
问题 #1. Validate EmailAddress on the Form I have a backend form class with an emailAddress property that has validation logic so that I can return an error message back to the user. I validate all form inputs with something like: $form->fillWith($request->input()); if($form->validate()){ $form->dispatch($command); // if synchronous, form takes command's messageBag } return response($form->getMessageBag()->toJson()); #2. Validate EmailAddress Value Object in the Command Handler I have a command

Should lookup values be modeled as aggregate roots?

丶灬走出姿态 提交于 2019-12-17 18:41:35
问题 As part of my domain model, lets say I have a WorkItem object. The WorkItem object has several relationships to lookup values such as: WorkItemType : UserStory Bug Enhancement Priority : High Medium Low And there could possibly be more, such as Status , Severity , etc... DDD states that if something exists within an aggregate root that you shouldn't attempt to access it outside of the aggregate root. So if I want to be able to add new WorkItemTypes like Task, or new Priorities like Critical,

Where to put global rules validation in DDD

ぐ巨炮叔叔 提交于 2019-12-17 17:19:06
问题 I'm new to DDD, and I'm trying to apply it in real life. There is no questions about such validation logic, as null check, empty strings check, etc - that goes directly to entity constructor/property. But where to put validation of some global rules like 'Unique user name'? So, we have entity User public class User : IAggregateRoot { private string _name; public string Name { get { return _name; } set { _name = value; } } // other data and behavior } And repository for users public interface

Should Entities in Domain Driven Design and Entity Framework be the same?

不问归期 提交于 2019-12-17 15:51:45
问题 I have started using Entity Framework Code First for the first time and am impressed by the way in which our greenfield application is being built around the domain rather than around the relational database tables (which is how I have worked for years). So, we are building entities in C# that are being reflected in the database every time we do a new migration. My question is this: should these same entities (i.e. designed with Entity Framework in mind) play the same role as entities in