Entity SQL language 5 groupby, bit handler, string Handler

Source: Internet
Author: User
Groupby

You can use the following syntax to query data by group:

string entitySQL = @"SELECT o.OrderDate, Count(o.OrderID) AS Count 
FROM Orders AS o GROUP BY o.OrderDate";
var query = db.CreateQuery<DbDataRecord>(entitySQL);

Directly perform the group by Operation

You can also use the count, Max, Min, sum, and AVG functions for grouping.

The usage is similar to that of SQL.

Function

The function is somewhat different from the general SQL statement. Here are some examples.

Bitwise AND, Or, exclusive or operation:

DB. createquery <int32> (@ "bitwiseand (1, 0)") // only 1 for all 1
DB. createquery <int32> (@ "bitwiseor ()") // or 1 is 1
DB. createquery <int32> (@ "bitwisexor ()") // The difference or difference is 1

String processing(Many examples of samplequeries have errors. Please check the machine and correct them. The following examples are correct examples):

DB. createquery <int32> ("indexof ('D', 'zhongdian ')") // obtain the position of the preceding string in the string following it. In this example, the result is 6.
DB. createquery <string> ("right ('zhongdian ', 3)") // right returns the string with a length of 3, Ian
DB. createquery <string> ("Left ('zhongdian ', 4)") // string with a length of 4 on the left, zhon
DB. createquery <string> ("length ('abc')") // String Length, 3
DB. createquery <string> ("substring ('zhongdian ', 2, 3)") // substring, starting from index 2, taking length 3, hon
DB. createquery <string> ("ltrim ('text')") // remove the left space, "text"
DB. createquery <string> ("rtrim ('text')") // remove the right space, "text"
DB. createquery <string> ("Trim ('text')") // remove spaces on both sides, "text"
DB. createquery <string> ("Replace ('zhongdian ', 'zhong', 'chong ')") // replace parameter 2 in parameter 1 with parameter 3, chongdian
DB. createquery <string> ("tolower ('abc')") // convert it to lowercase, ABC
DB. createquery <string> ("toupper ('abc')") // convert to uppercase, ABC
DB. createquery <string> ("reverse ('abc')") // reverse, CBA

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.