No nonsense, or first git. Address: Https://gitee.com/jimmyTown_admin_admin/DapperInCoreDemo.git
The structure is as follows:
1. In the framework era, Dapper was heavily used and developed by many programmers because of its small, light but easy-to-use and efficient use. Compared to the pet of EF, I also prefer to use dapper, today just have a free, I wrote the corresponding Deamo (Demo 2 part, part of the. NET Core console, part of ASP.
Development environment: VS2017. NET Core 2.1.3 IIS7.
2. Structure Description:
Dapperincorelib references in Dapper
Oracle.ManagedDataAccess.Core
After referencing OK, the corresponding generic interface is defined according to the dapper package
Mainly for the implementation of dapper itself for some curd package
1.2 Next to the interface for the corresponding implementation, here will consider compatible with sqlserver/oracle or other db (currently only implemented in these 2, but actually also support mysql/sqlite, etc.)
The corresponding connection string and connection type are used to drive the implementation.
For example, when the query is directly using idbconection as the connection, the other part of the same
1.3 Dapperfactory
There are 2 main blocks here.
The first part implements the singleton: access point for all connections
Part II: Obtaining an interface for operations
1. 4 Simple Warehousing implementation
Interface section (slightly, please look directly at the code), the implementation section:
Then look at part 2nd: the corresponding Webapi section (main 1. Injection 2.Swagger, 3.log4net)
Introduction of Swashbuckle.aspnetcore and Log4net
2.1 Configuring IOC injection and swagger
2.2 Configuring Log4net
Of course, the log can also be used without the use of log4net and Microsoft.Extensions.Logging under the Iloggerfactory
Run a look at the effect (I'll change the start URL in Lauchsetting.json to "Launchurl": "Api/student"
Show all student information by default, we can go to Swagger page
Here is not a try, you can download the code to try
ASP. NET core uses dapper Operation Sqlserver/oracle