First, the basic concept
The ABP is "ASP. Boilerplate Project (ASP. NET Template project) "for short.
ABP was developed by the Turkish architect Hikalkan and now joins a ismcagdas developer.
ASP. Boilerplate is a new starting point for developing modern web applications with best practices and popular technologies, and is designed to be a common Web application framework and project template.
ABP's official website: http://www.aspnetboilerplate.com
Open source project on GitHub: Https://github.com/aspnetboilerplate
Strongly recommended to engage. NET programmer to learn.
Second, technical points
1. Service Side
Based on the latest. NET Technology (currently ASP 5, Web API 2, C # 5.0, will be upgraded after ASP. 5 is officially released)
Implement domain driven design (entities, warehousing, Domain Services, domain events, application services, data transfer objects, work units, etc.)
Implement tiered architecture (domain, application, presentation, and infrastructure tiers)
Provides an infrastructure to develop reusable, configurable modules
Integrate some of the most popular open source frameworks/libraries, perhaps some of which you are using.
Provides an infrastructure that makes it easy to use dependency injection (using Castle Windsor as a container for dependency injection, why not use the AUTOFAC?? )
Provides repository warehousing mode support for different ORM (entity Framework, NHibernate, Mangodb, and memory databases implemented)
Support and implement database migration (Code first for EF)
Modular development (each module has a separate EF DbContext, which can be specified independently of the database)
Includes a simple and flexible multi-lingual/localized system
Includes a eventbus to implement server-side global domain events
Uniform exception Handling (the application layer hardly needs to handle its own write exception handling code)
Data validation (ASP. NET MVC can only do the parameter validation of the action method, the ABP implements the parameter validation of the application layer method)
Automatically create the Web API layer with application services (no need to write Apicontroller layer)
Providing base classes and helper classes allows us to easily implement some common tasks
Using "Conventions over configuration principles"
2, the Client
Bootstrap, less, AngularJs, JQuery, Modernizr, and other JS libraries: Jquery.validate, Jquery.form, Jquery.blockui, Json2
Project templates are provided for single-page applications (AngularJs, DURANDALJS) and multi-page applications (bootstrap+jquery).
Automatically create a proxy layer of JavaScript to make it easier to use the web Api
Encapsulates JavaScript functions to make it easier to use AJAX, message boxes, notification components, matte layers for busy states, and more
3. Zero Module
Authentication and authorization management (implemented through ASP. NET identity)
User & Role Management
System Settings Access Management (System level, tenant level, user level, scope automatic management)
Audit logs (automatically record callers and parameters for each interface)
The above excerpt from yangming series Tutorials
Third, from the ABP official website to obtain template
ABP Template Address: http://www.aspnetboilerplate.com/Templates
1, choose to choose MPA, because Angularjs or durandaljs do not understand;
2, select the ORM Framework (Entity Framework or nhibernate) I choose EF;
3, Zero module first do not select
4, from a name, I started the FIRSTABP
Click "CREATE MY PROJECT" To download a zip archive and open the following structure with vs2013:
The ABP components and other third-party components that are referenced in each project are opened and need to be re-referenced by NuGet.
Build to see if there are any errors, then set Firstabp.web as the starter project, F5
Four, simple demo
1. Create a new people folder in Firstabp.core, and then build a person entity
using Abp.Domain.Entities; namespace firstabp.people{ public class person:entity { public virtual string Name {get ; set public virtual int ? Age {get ; set
The entity inherits the Abp.Domain.Entities.Entity base class, which, by default, has an int type self-increment ID, if you want to specify it with a different type, such as Abp.domain.entities.entity<string>
2. Add the new person entity class to Idbset
Inside the Firstabpdbcontext file under the Firstabp.entityframework Class Library EntityFramework folder
usingSystem.Data.Entity;usingabp.entityframework;usingfirstabp.people;namespacefirstabp.entityframework{ Public classFirstabpdbcontext:abpdbcontext {//Todo:define an idbset for each Entity ... Public Virtualidbset<person> Person {Get;Set; } //Example://Public Virtual idbset<user> Users {get; set;} /*Note: * Setting "Default" to base class helps us if working migration commands on package Manager Consol E. * But it could cause problems when working Migrate.exe of EF. If you'll apply migrations on command line, don't * Pass connection string name to base classes. ABP works either. */ PublicFirstabpdbcontext ():Base("Default") { } /*Note: * This constructor are used by ABP to pass connection string defined in Firstabpdatamodule.preinitiali Ze. * Notice, actually you won't directly create an instance of Firstabpdbcontext since ABP automatically handles it . */ PublicFirstabpdbcontext (stringnameorconnectionstring):Base(nameorconnectionstring) {} }}
3. Database migrations creating libraries and tables
Firstabp.web Webconfig, automatic creation of FIRSTABP database
< connectionStrings > < name= "Default" connectionString= "server=localhost; DATABASE=FIRSTABP; trusted_connection=true; " ProviderName = "System.Data.SqlClient" /> </ connectionStrings >
Modify the Configuration.cs file under the Migrations folder under the Simpletasksystem.entityframework project
usingSystem.Data.Entity.Migrations;usingfirstabp.people;namespacefirstabp.migrations{Internal Sealed classConfiguration:dbmigrationsconfiguration<firstabp.entityframework.firstabpdbcontext> { PublicConfiguration () {automaticmigrationsenabled=false; Contextkey="FIRSTABP"; } protected Override voidSeed (FirstABP.EntityFramework.FirstABPDbContext context) {//This method is called every time after migrating to the latest version. //You can add any seed data here ...context. Person.addorupdate (P=P.name,Newperson {Name ="joye.net", age= - }, Newperson {Name ="Jerry.core", age= - }, Newperson {Name ="Longhao", age= - }, Newperson {Name ="XMM", age= - }); } }}
Through the tools, NuGet Package Manager-> Package Manager console, the default project needs to be selected Firstabp.entityframework,add-migration "Initialcreate" to create
Generate a 201605170608193_initialcreate.cs file under the Migrations folder
namespacefirstabp.migrations{usingSystem; usingSystem.Data.Entity.Migrations; Public Partial classinitialcreate:dbmigration { Public Override voidUp () {createtable ("dbo. People", C=New{Id= C.int (Nullable:false, Identity:true), Name=c.string (), age=c.int (),}) . PrimaryKey (t=t.id); } Public Override voidDown () {droptable ("dbo. People"); } }}
Continuing with "update-database" will automatically create the corresponding data table in the database:
If the problem occurs, the NuGet version may be too low and need to be upgraded under
4. Define the Storage interface
New IPersonRepository.cs under people of Firstabp.core class library
using System; using System.Collections.Generic; using Abp.Domain.Repositories; namespace firstabp.people{ publicinterface Ipersonrepository:irepository<person,int32 > { List<Person> getpersons ();} }
5. Realize Storage interface
PersonRepository.cs file for repositories files under Firstabp.entityframework class library EntityFramework
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingabp.entityframework;usingfirstabp.people;namespacefirstabp.entityframework.repositories{ Public classPersonrepository:firstabprepositorybase<person,int32>, ipersonrepository { PublicPersonrepository (idbcontextprovider<firstabpdbcontext> dbcontextprovider):Base(Dbcontextprovider) {} PublicList<person>getpersons () {//in the warehousing method, the ABP framework is automatically processed without processing database connections, DbContext, and data transactions. //GetAll () returns a iqueryable<t> interface type varquery =GetAll (); returnQuery. OrderByDescending (p=>p.id). ToList (); } }}
6. Create Domain Services (firstabp.application)
Interface
using Abp.Application.Services; using FirstABP.People.DTO; namespace firstabp.people{ publicinterface ipersonservice:iapplicationservice { getallpeopleoutput getpersons (); }}
Realize:
usingSystem.Collections.Generic;usingAbp.Application.Services;usingAutoMapper;usingFirstABP.People.DTO;namespacefirstabp.people{ Public classPersonservice:applicationservice, Ipersonservice {Private ReadOnlyipersonrepository _personrepository; /// <summary> ///Auto-injection of constructor function/// </summary> /// <param name= "Personrepository" ></param> PublicPersonservice (ipersonrepository personrepository) {_personrepository=personrepository; } Publicgetallpeopleoutput getpersons () {varPersons =_personrepository.getpersons (); //automatically convert list<peopson> to list<peopsondto> with AutoMapper return NewGetallpeopleoutput {People= mapper.map<list<persondto>>(Persons)}; } }}
7. Get the call in the Web
Code:
usingSYSTEM.WEB.MVC;usingfirstabp.people;namespacefirstabp.web.controllers{ Public classHomecontroller:firstabpcontrollerbase {Private ReadOnlyIpersonservice _personservice; PublicHomeController (Ipersonservice personservice) {_personservice=Personservice; } PublicActionResult Index () {//Get list varp =_personservice.getpersons (); returnView ("~/app/main/views/layout/layout.cshtml");//Layout of the angular application. } }}
Operation Result:
Finally, look at the new code:
Code Download: https://yunpan.cn/cSwC9CbNtDMFt Access password 788c
In-depth study recommended to
Yangming Series Tutorial: http://www.cnblogs.com/mienreal/p/4528470.html
TKB to Jane series Tutorial: http://www.cnblogs.com/farb/p/ABPTheory.html
Research on the ABP development framework based on DDD