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:
DbSession.Default.From<Products>().Select(Products._.ProductID).Top(1).ToScalar<int>();
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.