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!