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