Dapper Introduction
Dapper has only one code file, fully open source, you can put in the project anywhere, to achieve data-to-object ORM operation, small volume speed. The advantage of using ORM is to increase, delete, change quickly, do not have to write their own SQL, because this is a repetitive technical content of the work, there is a large number of programs to read from the database and then create model, and assign values to the Model field. These ORM can be easily done for you. When ORM facilitates our development, performance is also a problem that we have to consider. General ORM Performance and direct write native SQL is much worse, but Dapper performance is also very wrong, even and Dbhelpersql mode performance is much higher.
If you like native SQL statements and you like the simplicity of ORM, then you will love the dapper ROM.
Dapper
Dapper function implementation
1 Dapper Function Implementation2 /// <summary>3 ///Execute SQL statement4 /// </summary>5 /// <param name= "strSQL" ></param>6 /// <returns></returns>7 Public intExecutebysql (stringstrSQL)8 {9 if(Dbtransaction = =NULL)Ten { One using(varConnection =Connection) A { - returnconnection. Execute (strSQL); - } the } - Else - { -DbTransaction.Connection.Execute (strSQL,NULL, dbtransaction); + return 0; - + } A } at /// <summary> - ///executes the SQL statement with the parameter - /// </summary> - /// <param name= "strSQL" ></param> - /// <param name= "DbParameter" ></param> - /// <returns></returns> in Public intExecutebysql (stringstrSQL,paramsdbparameter[] dbparameter) - { to if(Dbtransaction = =NULL) + { - using(varConnection =Connection) the { * returnconnection. Execute (strSQL, dbparameter); $ }Panax Notoginseng } - Else the { + DbTransaction.Connection.Execute (strSQL, DbParameter, dbtransaction); A return 0; the + } - } $ /// <summary> $ ///Executing stored procedures - /// </summary> - /// <param name= "procname" ></param> the /// <returns></returns> - Public intExecutebyproc (stringprocname)Wuyi { the if(Dbtransaction = =NULL) - { Wu using(varConnection =Connection) - { About returnconnection. Execute (procname); $ } - } - Else - { ADbTransaction.Connection.Execute (ProcName,NULL, dbtransaction); + return 0; the - } $ } the /// <summary> the ///executes a stored procedure with parameters the /// </summary> the /// <param name= "procname" ></param> - /// <param name= "DbParameter" ></param> in /// <returns></returns> the Public intExecutebyproc (stringProcName,paramsdbparameter[] dbparameter) the { About if(Dbtransaction = =NULL) the { the using(varConnection =Connection) the { + returnconnection. Execute (procname, dbparameter); - } the }Bayi Else the { the DbTransaction.Connection.Execute (procname, DbParameter, dbtransaction); - return 0; - the } the}
C # Dapper Lightweight ORM Debugging for SQL Server