The wording of the condition in dapper

Source: Internet
Author: User

Today with the dapper update is used in the writing, the garden to find an article to write

Traditional SQL in (dapper) is written like this

Conn. Query<users> ("SELECT * from Users s WHERE s.id in (@ids)", new {ids = new int[]{1,2,3}}) conn. Query<users> ("SELECT * from Users s WHERE s.id in (@ids)", new {ids = Ids.toarray ()})

After the use of the show,

System.Data.SqlClient.SqlException: "", "there is a syntax error nearby. ”

Such a hint,

When you trace an SQL statement, you find that the SQL statement generated by the method is as follows:

exec sp_executesql N'update websitechanellistpage set status=0 where ID in ((@ilist1, @ilist2))  ', N'@ilist1 int, @ilist2 int',@ilist1=1,  @ilist2=2

It is not difficult to find that the resulting statement has a layer of parentheses in it, so the fruit segment modifies the code:

= "updateset status=0wherein@ilist"; Connection. Execute = idlist. ToArray ()});

Successful execution! Problem Solving!

Of course there may be my Dapper version of the problem, I used to be: Dapper 1.50.4.0

The wording of the condition in dapper

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.