Database Component hxj. Data (12nd) wher.pdf Builder

Source: Internet
Author: User

Wheredia builder is a new class added in version 1.7.2 to create whereclip.

Create whereclip with multiple conditions in the previous version as follows:

WhereClip where = WhereClip.All;where = where.And(Products._.ProductName.Contain("apple"));where = where.And(Products._.UnitPrice > 1);where = where.Or(Products._.CategoryID == 2);

Each added condition generates a new whereclip.

 

Wheredia builder is used as follows:

WhereClipBuilder wherebuilder = new WhereClipBuilder();wherebuilder.And(Products._.ProductName.Contain("apple"));wherebuilder.And(Products._.UnitPrice > 1);wherebuilder.Or(Products._.CategoryID == 2);

Wheredia builder creates new instances without adding conditions to accumulate conditions, so as to be reused and save resources.

 

Specific use:

Northwind.From<Products>()                .Where(wherebuilder.ToWhereClip())                .ToList();

Generated SQL:

Text:     
SELECT * FROM [Products]
WHERE (((([Products].[ProductName] LIKE @jtioerxooyxzyvsj) AND ([Products].[UnitPrice] > @txdupnwvhfznviqj))
OR ([Products].[CategoryID] = @iqgkjykstppcrqsq)))

Parameters:
@jtioerxooyxzyvsj[String] = %apple%
@txdupnwvhfznviqj[Int32] = 1
@iqgkjykstppcrqsq[Int32] = 2

 

 

 

Download

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.