. NET lightweight ORM framework Dapper practice manual,. netormdapper practice

Source: Internet
Author: User


. NET lightweight ORM framework Dapper practice manual,. netormdapper practice

I. Summary


1.1 why is this sharing course called 《Practice Manual?


I hope some tips and skills involved in this sharing lesson will help you. We hope that you will reserve it as a practical skill manual for future work. Once you have something similar to the practice manual of Dapper, it can be used directly for reading and flexibly applied to projects. Finally, you are advised to constantly improve this manual based on the different use cases you encounter at work.


We don't need to talk much about it. We just need to get the dry goods directly. We don't make the dry goods, but we are just the porters of the dry goods.






4. knowledge points involved in coverage

1. C # Linq To Xml technology.


2. Transact-SQL practice manual. For example, how to use temporary tables, create user-defined tables (tables), XML data fields, ROW_NUMBER paging functions, and storage process training manual (dynamic SQL Execution, exception handling mechanism, and transaction processing mechanism) C # How to obtain the OUTPUT and RETURN parameters of a stored procedure.


3. SQL Sever FOR XML technology (simple usage of XML PATH, XML RAW, and XML AUTO ).


4. Use the keyword "OPENXML" to operate XML files in the memory.


5. Use Faker. Net in the same way as the test data framework.


6. Use of unit test NuitTest in.


7. Use of Dapper in Asyn Task.


8. Native Dapper's simple CRUD (add, delete, modify, and query) Training Manual.(Strongly recommended)


9. How does Dapper dynamically splice DynamicParameters to query the SQL practice manual.(Strongly recommended)


10. Dapper extension library Dapper. SqlBuilder and UniqueNamespace. SqlBuilder training manual.(Strongly recommended)


11. Native Dapper Advanced Skills Training Manual.(Strongly recommended)


12. Dapper extended library Dapper-Extensions training manual.(Strongly recommended)


V. Online demonstration of Dapper practice manual

5.1 native Dapper's simple CRUD (add, delete, modify, and query) Training Manual


Insert and Insert_Batch (batch Insert data ).


Update, Delete, and Exist.


GetById, GetList, and GetByIds (used by the in clause ).


GetListReturnDynamic (returns dynamic ).


GetListByMultiQuery (returns the multi-result set Tuple <TResult1, TResult2,...> ).


ExecuteWithDBTransaction (local DbTransaction transaction operation ).


ExecuteWithTransactionScope (Distributed TransactionScope transaction operation ).


5.2. How does Dapper use DynamicParameters to dynamically splice and query the SQL practice manual?


Insert and GetListByGenreIdAndName appreciate DynamicParameters.


SearchOrdersByPageDynamicParametersSqlBuild: obtains the paging data (by dynamically splicing the query SQL statement through DynamicParameters + ROW_NUMBER () OVER clause paging ).


SearchOrdersByDynamicParametersOutPutANDReturnVaule: describes how to use DynamicParameters to construct and obtain the OUTPUT and RETURN values of stored procedures, and obtain one or more result sets returned by stored procedures.


5.3 Dapper extension library Dapper. SqlBuilder practice manual


Use SqlBuilder to construct a CRUD statement template.


The SQL builder built-in template is used to construct SELECT (query) and Page (paging) Statement templates.


GetOrderOneToManyByDapperSqlBuilder: Get the "one-to-many" order by using the xml path clause of SQL syntax.


SearchOrdersByPageDapperSqlBuilder: obtains the paging data (through Dapper. SqlBuilder splicing + ROW_NUMBER () OVER clause paging ).


SearchOrdersByDapperDapperSqlBuilderSqlPagingTemplates to obtain the paging data (by using the paging template provided by Dapper. SqlBuilder built-in ).


5.4 native Dapper Advanced Skills Training Manual


CreateOrder: Create an order (using SQL concatenation + for loop ).


CreateOrderByStoredProcedures_XMLPath: creates an order (using the XMLPath method that generates XML + SQL XML data types ).


CreateOrderByStoredProcedures_OpenXml: Create an order (using the OpenXml method that generates XML + SQL XML data types ).


CreateOrderByStoredProcedures_CustomTableType: Create an order (use SQL to create a custom table type ).


GetOrderOneToManyBySqlBuilder: Obtain the order (one-to-many) using the SQL statement of the Master/Slave table.


GetOrderOneToManyByDapperQuery: Obtain the order (one-to-many) using the native Dapper Query + splitOn keyword.


SearchOrdersByPageSqlBuild: obtains the paging data (by splicing SQL statements + ROW_NUMBER () OVER clause paging ).


SearchOrdersByPageSqlStoredProcedures: obtains paging data (by using the SQL paging Stored Procedure + ROW_NUMBER () OVER clause paging ).


5.5 Dapper extended database Dapper-Extensions Training Manual


1. Insert and Insert_Batch (batch Insert data ).


2. Update, Delete, and Exist.


3. Insert_BatchBySqlBulkCopy (batch data insertion based on SqlBulkCopy ).


4. GetList: contains the following knowledge points:


* Query by condition (with filtering conditions and sorting fields ).


* Query by Multiple Combination conditions (filter condition + sorting field is generated through IPredicate Predicates. Group ).


* Query by Multiple Combination conditions (filter condition + sorting field is generated through IPredicate. Add ).


* Query Based on Multiple Combination conditions (filter condition + sorting field is generated by combining Predicate multi-condition composite predicates. Example SQL statement: select * From Table Where (id1 = @ id1 AND name2 = @ name2) OR (id2 = @ id2 AND name2 = @ name2 ).


* Subquery based on a single condition (through IPredicate. EXISTS () subquery filtering Condition Statement + sorting field. Example Statement: Select * Form Table Where Exists (Select 1 From Table Where id = @ id )).


* Subquery Based on Multiple Combination conditions (through IPredicate. EXISTS () subquery filtering Condition Statement + sorting field. Example Statement: Select * From Table Where Exists (Select Count (1) from Table Where (id1 = @ id1 AND name2 = @ name2) OR (id2 = @ id2 AND name2 = @ name2 ))).


* SearchOrdersByPageDapperExtensions: obtains paging data (through the provided extended DapperExtensions multi-condition combination composite predicate IPredicate + Built-in Count and Page functions ).


6. Online interpretation and demonstration of source code



VII. Summary

In the world of ADO. NET, the sky is soaring ".


The programming capability of Transact-SQL goes further.


Appreciate her "beauty" in Dapper "!


After learning this practice manual, you will get full of dry goods, so that you are more confident!


Follow-up plan:A stupid will bring you another sharing lesson 《. NET lightweight ORM Component Dapper practices, which may include Dapper For MSsql, Dapper For Mysql, Dapper For Oracle, Repository mode at the data access layer, and Dapper-based open-source warehouse mode project application, and so on.








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.