Database Component Hxj.data (27) (Field combination update)

Source: Internet
Author: User

Hxj.data V1.5.1 version begins to support field combination updates.

For example: Update table Set A=b+c

Update table Set a=a+1

(+ 、-、 *,/,%) by analogy.

Here is a concrete example. (examples are just for test results, no practical significance)

Example One,

DbSession.Default.Update<Products>(Products._.UnitPrice,  Products._.ReorderLevel + Products._.UnitPrice, Products._.ProductID == 1);

The generated SQL is as follows:

Text:

UPDATE [Products] SET [UnitPrice]=[Products].[ReorderLevel] + [Products]. [UnitPrice]
WHERE [Products].[ProductID] = @mjpxqimmtmiyguvv 

Parameters:

@mjpxqimmtmiyguvv [Int32] = 1

is to update the value of the UnitPrice field to the value of UnitPrice plus reorderlevel field.

Cases II,

Dbsession.default.update<products> (products._. UnitPrice, Products._. UnitPrice + 1, products._. ProductID = = 1);

The generated SQL is as follows:

Text:

UPDATE [Products] SET [UnitPrice]=[Products].[UnitPrice] +  @tszvynxwnukkjuzj
WHERE [Products].[ProductID] = @anuixieadujzvvka

Parameters:

@tszvynxwnukkjuzj[Int32] = 1
@anuixieadujzvvka[Int32] = 1

Here is the value of the UnitPrice field plus 1.

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.