ASP.NET Boilerplate
2015-12-10 01:45
387 查看
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.
开始吧!
特点:继承、自动、约定、扩展
领域层:领域实体、业务规则、操作数据库、
应用层:单元操作、数据传输对象、输入输出对象、应用服务(接口与实现)
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.
开始吧!
相关文章推荐
- asp.net接收发送的xml字符串数据
- ASP.NET Core 1.0 中的依赖项管理
- ASP.NET中字段赋值问题
- ASP.NET 问题集锦
- ASP.NET MVC 监控诊断、本地化和缓存
- asp.net列表分页
- @AspectJ使用示例
- ASP.NET MVC
- ASP.NET发送电子邮件
- ASP.net MVC自定义错误处理页面的方法
- ASP.NET MVC 发送邮件(异步)
- ASP.NET中实体数据库模型的增删改查的用法。
- asp.net关于post和get传值的问题
- vs2013 asp.net System.BadImageFormatException
- ASP.NET Web API 应用教程(一) ――数据流使用
- but no declaration can be found for element 'aop:aspectj-autoproxy'.
- ASP.NET Web API 应用教程(一) ——数据流使用
- ASP.NET MVC 实现与SQLSERVER的依赖缓存
- ASP.NET状缓存Cache的应用-提高数据库读取速度
- MVC6 (ASP.NET5) 认证 (Asp.net identity) cookie模式 自定义认证