forked from cyq1162/cyqdata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSqlValue.cs
101 lines (94 loc) · 3.56 KB
/
SqlValue.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
namespace CYQ.Data.SQL
{
/// <summary>
/// 用于多数据库兼容的替换关键字/函数
/// </summary>
public class SqlValue
{
/// <summary>
/// 对于Bit类型[是/否] 类型的排序:[#DESC]
/// </summary>
public const string Desc = "[#DESC]";
/// <summary>
/// 对于Bit类型[是/否] 类型的排序:[#ASC]
/// </summary>
public const string Asc = "[#ASC]";
/// <summary>
/// 对于Bit类型[是/否] 的条件值:[#TRUE]
/// </summary>
public const string True = "[#TRUE]";
/// <summary>
/// 对于Bit类型[是/否] 的条件值:[#FALSE]
/// </summary>
public const string False = "[#FALSE]";
/// <summary>
/// 数据库函数 Len 取长度:[#LEN](字段)
/// </summary>
public const string Len = "[#LEN]";//length
/// <summary>
/// 数据库函数 GUID 获取:[#GETDATE]
/// </summary>
public const string GUID = "[#GUID]";
/// <summary>
/// 数据库函数 ISNULL 判断:[#ISNULL](Exr1,Exr2)
/// </summary>
public const string ISNULL = "[#ISNULL]";
/// <summary>
/// 数据库函数 GetDate 获取当前时间:[#GETDATE]
/// </summary>
public const string GetDate = "[#GETDATE]";
/// <summary>
/// 数据库函数 Year 获取时间的年:[#YEAR](字段)
/// </summary>
public const string Year = "[#YEAR]";
/// <summary>
/// 数据库函数 Month 获取时间的月:[#MONTH](字段)
/// </summary>
public const string Month = "[#MONTH]";
/// <summary>
/// 数据库函数 Day 获取时间的日:[#DAY](字段)
/// </summary>
public const string Day = "[#DAY]";
/// <summary>
/// 数据库函数 Substring 截取字符串:[#SUBSTRING](字段,起始索引int,长度int)
/// <example>
/// <code>
/// 示例: [#Substring](Title,0,2)
/// </code>
/// </example>
/// </summary>
public const string Substring = "[#SUBSTRING]";
/// <summary>
/// 数据库函数 CharIndex 查询字符所在的位置:[#CHARINDEX]('要查询的字符',字段)
/// <example>
/// <code>
/// 示例: [#CHARINDEX]('findtitle',Title)>0
/// </code>
/// </example>
/// </summary>
public const string CharIndex = "[#CHARINDEX]";
/// <summary>
/// 数据库函数 DateDiff 比较日期的差异天数:[#DATEDIFF](参数,开始时间,结束时间)
/// </summary>
public const string DateDiff = "[#DATEDIFF]";
/// <summary>
/// 数据库函数 Case 分支语句,其它Case 一起的关键字也需要包含。
/// <example>
/// <code>
/// 示例: [#CASE] [#WHEN] languageID={1} [#THEN] {2} [#ELSE] 0 [#END]
/// </code>
/// </example>
/// </summary>
public const string Case = "[#CASE]";//单条件分支
/// <summary>
/// 数据库函数 Case When 分支语句,其它Case 一起的关键字也需要包含。
/// <example>
/// <code>
/// 示例: [#CASE#WHEN] languageID={0} [#THEN] 1000000 [#ELSE] 0 [#END]
/// </code>
/// </example>
/// </summary>
public const string CaseWhen = "[#CASE#WHEN]";//多条件分支
}
}