Get the App
SLTechnology News&Howtos  ›  Development  › 

How to create and use ABP to introduce Dapper framework

Shulou Source: shulou.com Published: 2022-05-31 18:47:33 09月21日 Update

This article mainly explains "how to create and use ABP to introduce Dapper framework", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "ABP introduces how to create and use Dapper framework"!

one。 First, prepare a database to build a table.

two。 Create an entity table [Table ("BasBloodLevel")] public class BasBloodLevel:Entity {public string Code {get; set;}} III. Then install the Abp.Dapper package on the EF layer of the ABP framework

Abp.Dapper package

And add the following code to the xxxEntityFrameworkModule of the EF layer

This is done referencing the Dapper framework, and the next step is to use the

Use the first DbContext to introduce the corresponding DbSet

Finally, it is directly used in the application layer.

Warehousing using IDapperRepository can use Dapper's ORM framework.

Public class BasBloodLevelAppService: IApplicationService {private readonly IDapperRepository _ basBloodLevelRepository; public BasBloodLevelAppService (IDapperRepository basBloodLevelRepository) {_ basBloodLevelRepository = basBloodLevelRepository;} public List GetBasAllMessage2 () {var entity = _ basBloodLevelRepository.Query ("select * from BasBloodLevel") .ToList (); return entity;}}

Call the following to prove that I am successful

At this point, I believe you have a deeper understanding of "how to create and use the Dapper framework introduced by ABP". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Framework content learning practicality deeper success next code interest entity practicality practicality that is application layer simple operation data database method more friends. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Linux macOS Apple MariaDB