Database Component hxj. Data (21) (toscalar)

Source: Internet
Author: User

After the weekend, we released component 1.0.

The component is extended. The biggest modification is to add cache queries for better performance.


This section describes some small extension modifications.


Previous versions of toscalar () only return objects.

Now the toscalar <tresult> () method is added, and the component automatically converts the type.

For example:


In this way, the return type is int type, eliminating the need for conversion code.

If the queried value is null or dbnull, default (tresult) is returned for this conversion ).


The dbsession method is extended as follows:

Sum <tentity, tresult> (field, whereclip where)

Max <tentity, tresult> (field, whereclip where)

Min <tentity, tresult> (field, whereclip where)

AVG <tentity, tresult> (field, whereclip where)

Return the required type.

For example:

DbSession.Default.Avg<Products,decimal>(Products._.UnitPrice, WhereClip.All);

In this way, data of the decimal type is returned.


Dbsession also adds exists <tentity> (whereclip where)

Determines whether a record exists and returns bool.


The next section describes cache queries.

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: 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.