First knowledge of Dapper

Source: Internet
Author: User

Developing a project at the end of 16, the project for auction, Snow is a challenge for me, a non-programmer. Program Ape the industry is to learn to use old. Individuals prefer SQL Native writing, EF still not cold, ef although strong, but it is not easy to use. At the same time the method of Dapper asynchronous async, measured repeatedly or decided to use Dapper, because the company used the MSSQL so in this is based on MSSQL grammar.
Dapper Source: https://github.com/StackExchange/dapper-dot-net
I. Project References

Direct search in NuGet Add reference

Second, basic grammar


1. Add references in the class library

Individuals prefer to write native SQL, although handwriting is less efficient, but can keep the code fun. Of course, many times also use tool software to generate additions and deletions of the statement ...
The basic syntax is no longer mentioned, the parameterization, transaction, multi-statement query

(1) Parameterization:
Dapper used to be,

Dynamicparameters p = new Dynamicparameters ();

Use the following method

(2) Execution of services

Here the two strSQL is the Update method, the entire process: Open link-open transaction-execution Method-Error rollback/Successful commit-close link, Ps:dapper also have Dbconnection.dispose () method, with colleagues to remind the best or directly close.

(3) Multi-statement query
To reduce the number of database queries, request multiple data at one time

Like other Orm, Dapper also requires entities to correspond to data fields.

Many dapper methods do not say much.

First knowledge of Dapper

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.