ASP.NET Boilerplate

I want it to be a start point for all we .NET developers, so, it will be good to develop it together.

特点:继承、自动、约定、扩展

领域层:领域实体、业务规则、操作数据库、

应用层:单元操作、数据传输对象、输入输出对象、应用服务(接口与实现)

Domain layer

In the Domain Driven Design (DDD), the core layer is the Domain Layer. Domain Layer defines your Entities, implements your business rules and so on.

Application layer

Application layer does not include domain information and business rules in an ideal application (this may not be possible in the real life but we should minimize it). It mediates between presentation layer and domain layer.

Notice that I did not call _taskRepository.Update or any other method to save changes to database. Because, an application service method is a unit of work as default in ASP.NET Boilerplate. For a unit of work method, it basically opens a database connection and begins transaction at the beginning of the method and saves all changes (commits the transaction) to database at the end of the method automatically. It rollbacks the transaction if an Exception is thrown in the execution of the method.

application layer depends only domain (core) layer of the application

DTO Validation:

Validating the user input is an application-layer task.

An application service method should validate inputs and throw exceptions if given input is not valid.

But an Application service is a plain class, not derived from Controller. Fortunately, ABP provides similar mechanism for ordinary application service methods (using Castle Dynamic proxies and interception).

One more thing: ABP checks if input parameter of a service method is null. So, you don't need to write guard clauses for that.

I advice to create seperated input and output classes for each application service method even it has only one input argument. This is good when extending the application by adding other arguments to this method. It provides a way of adding parameters to the application service method without breaking existing clients.

开始吧!

原文地址:https://www.cnblogs.com/heifengwll/p/5034819.html