Dappers: daos Based on dapper.net Extension

Source: Internet
Author: User
One day I saw dapper.net in the garden, and finally found my consistent queue OM (Object mapping) (someone, you know ....). from Java. net, from spring.net 0.6 to spring.net 1.3.2, has been using hibernate, but this ORM-relation processing has been abandoned by me. now I finally got my wish and immediately began to encapsulate it. function Expansion: 1. valuetype type implicit conversion. If a numeric is int64 in Oracle but decimal in SQL Server, implicit conversion must be added to dynamicmethod. 2. large clob fields are supported. the XML type of dapper cannot be used. 3. weak type conversion of the result set. For example, idictionary is used as the request parameter or DTO 4. added non-generic interface query 5. processing output parameters (Oracle cursor processing and output parameter READING) 6. simple SQL, automatic assembly of paging statement processing (top order, rownum, skip/take) 7. automatically replace the parameter prefix 8 According to dbprovider. implement SQL. SP calls are completely transparent and compatible with Oracle/SQL Server 9. the SQL crud statement and the partial update statement are automatically generated. 10. supports connection and transaction management in osiv mode (IMITATING spring. net sessionscope )----------- // Delete a user
Myuser u = New Myuser () {id = " Testid " };
Dao. Execute (queryinfo. getsqlupdate ( Typeof (Myuser), U ); 1 // SP returns two result sets with 10 rows of users and offices, and returns the total functions of both tables.
2 Queryinfo info = New Queryinfo ();
3 Info. namedquery = " Test_dapper_users " ;
4 Info. addparam ( " Usercode " , " Y % " );
5 Info. addparam ( " Out_totalcount " , 1 );
6 Info. addparam ( " Out_totalcount2 " , 1 );
7 Info. addparam ( " Out_cursor1 " , " Cursor " );
8 Info. addparam ( " Out_cursor2 " , " Cursor " );
9
10 VaR reader = Dao. querymultiple (Info );
11
12 VaR user = reader. Read <myuser> ();
13 VaR Office = reader. Read <myoffice> ();
14
15 Object I = reader. outputparams [ " Out_totalcount " ];
16 Object J = reader. outputparams [ " Out_totalcount2 " ]; Idictionary < String , Object > Param = New Dictionary < String , Object > ();
Param. Add ( " Usercode_rlk " , " Chen " ); // ==> And usercode like: usercode/'chen %'
Param. Add ( " Createdon_geq " , " 2011-09-01 " ); // ==> And createdon >=: createdon
Param. Add ( " Isactive " , 1 ); // ==> And isactive =: isactive

Queryinfo info = New Queryinfo ( " Sys_user u " );
Info. orderby. Add ( " Name " );

info. addparam (PARAM);
info. totalcount = 1 ; // paging requests
info. pagesize = 15 ;
info. startrecord = 10 ;
info. mappingtype = typeof (myuser);
info = Dao. query (Info);

// info. list = ilist [10] results of (myuser)
// info. totalcount = counts of the table ------------ the dapper implementation is very good, but some defects exist in my application scenarios, in addition, the implementation of static methods leads to the intrusion of the Code , which may cause some hidden risks in the subsequent dapper synchronization and upgrade. currently, 10 nunit use cases are supported. if you are interested in using dapper, I would like to help you with your questions about expansion and application ~~

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.