Database component Hxj.data (32) Whereclipbuilder

Source: Internet
Author: User

Whereclipbuilder is a new class in version 1.7.2 that is used to create whereclip.

The previous version Whereclip was created 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);每增加一个条件都是生成一个新的WhereClip。

Use Whereclipbuilder as follows:

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

Whereclipbuilder is to create new instances without adding conditions, thus reusing and saving 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: http://www.cnblogs.com/huxj/archive/2009/11/21/1607791.html

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.