Go [Dapper] SQL Experience Set

Source: Internet
Author: User

Condition. Append ("and  chinesename like @name");p. ADD ("@name" " % " " % ", System.Data.DbType.String);

Like can also parameterize queries.

@a The parameter notation of MSSQL

: A parameter notation for Oracle

? Parameter notation for OLE DB

In Access * indicates fuzzy matching

Mssql/oracle in% indicates fuzzy matching

Access 2000 is used for "Provider=Microsoft.Jet.OLEDB.4.0" in the default OLE DB connection for the source, which does not support the Replace function.

The Dapper is a lightweight ORM that can be conveniently used in. NET projects.

Conn. Query<users> ("SELECT * from the Users WHERE ID in @ids", new {ids = new string[] {"A", "B"}}). ToList (); So you can reach the target of in-parameterized queries. Conn. Querysingle<string> ("Select Count (*) from the Users where str like @a", new {a = "%bx%"}, Tran);
using(IDbConnection conn =NewSqlConnection ("Data Source=.;i Nitial catalog=test;integrated security=true") {Conn.    Open (); using(IDbTransaction tran =Conn. BeginTransaction ()) {Conn. Execute ("Update table1 set ic= ' 1 ' where [email protected]",New{a ="123"}, Tran); Conn. Execute ("update table2 set ic= ' 3 ' where [email protected]",New{a ="1234"}, Tran);    Tran.commit (); }}

This is an example of invoking a transaction using Dapper.

Go [Dapper] SQL Experience Set

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.