Dapper learning, dapper

Source: Internet
Author: User

Dapper learning, dapper

We have introduced Dapper queries, stored procedures, and function calls. Next we will talk about the addition, deletion, and modification of Dapper. In fact, the addition, deletion, and modification of Dapper are all in the same mode.

I will not introduce them separately. It will be displayed in an example.

Var sqlExec = @ "/* added */insert into tch_teacher (Sex, Name, IsDoublePosition, CreateDate) values (@ Sex, @ Name, @ IsDoublePosition, @ CreateDate ); /* modify */update tch_teacher set Name = CONCAT (name, LAST_INSERT_ID () where Id = @ Id;/* delete */delete from tch_teacher where Id = @ Id ;"; tch_Teacher teacher = new Tch_Teacher {Id = 100, Sex = Gender. male, Name = "Elvinle", IsDoublePosition = false, CreateDate = DateTime. now}; var resExec = conn. execute (sqlExec, teacher); Console. writeLine (resExec );

They can all be parameterized, Which is simpler and clearer and does not need to be managed too much.

In some ORM, the parameter is not written in this way, but in the "@ 0, @ 1" method. It is disgusting, unclear, and inconvenient to use. It is similar to string. format ()-like

In fact, there is nothing to introduce, delete, modify, and delete. So let's just talk a little bit about it. It's just for the sake of integrity. Sorry!

 

Related Article

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.