1
1
using System . Collections ;
2
2
using System . Linq ;
3
- using System . Collections . Generic ;
4
-
5
- namespace ServiceStack . OrmLite
6
- {
7
- public static class Sql
8
- {
3
+ using System . Collections . Generic ;
4
+
5
+ namespace ServiceStack . OrmLite
6
+ {
7
+ public static class Sql
8
+ {
9
9
public static bool In < T , TItem > ( T value , params TItem [ ] list )
10
10
{
11
11
return value != null && Flatten ( list ) . Any ( obj => obj . ToString ( ) == value . ToString ( ) ) ;
12
12
}
13
13
14
- public static List < object > Flatten ( IEnumerable list )
14
+ public static List < object > Flatten ( IEnumerable list )
15
15
{
16
16
var ret = new List < object > ( ) ;
17
- if ( list == null ) return ret ;
17
+ if ( list == null ) return ret ;
18
18
19
19
foreach ( var item in list )
20
20
{
@@ -33,35 +33,66 @@ public static List<object> Flatten(IEnumerable list)
33
33
return ret ;
34
34
}
35
35
36
- public static string Desc < T > ( T value )
37
- {
38
- return value == null ? "" : value . ToString ( ) + " DESC" ;
39
- }
40
-
41
- public static string As < T > ( T value , object asValue ) {
42
- return value == null ? "" : string . Format ( "{0} AS {1}" , value . ToString ( ) , asValue ) ;
43
- }
44
-
45
- public static T Sum < T > ( T value ) {
46
- return value ;
47
- }
48
-
49
- public static T Count < T > ( T value ) {
50
- return value ;
51
- }
52
-
53
- public static T Min < T > ( T value ) {
54
- return value ;
55
- }
56
-
57
- public static T Max < T > ( T value ) {
58
- return value ;
59
- }
60
-
61
- public static T Avg < T > ( T value ) {
62
- return value ;
63
- }
64
- }
65
-
66
- }
67
-
36
+ public static string Desc < T > ( T value )
37
+ {
38
+ return value == null ? "" : value . ToString ( ) + " DESC" ;
39
+ }
40
+
41
+ public static string As < T > ( T value , object asValue )
42
+ {
43
+ return value == null ? "" : string . Format ( "{0} AS {1}" , value . ToString ( ) , asValue ) ;
44
+ }
45
+
46
+ public static T Sum < T > ( T value )
47
+ {
48
+ return value ;
49
+ }
50
+
51
+ public static string Sum ( string value )
52
+ {
53
+ return "SUM({0})" . Fmt ( value ) ;
54
+ }
55
+
56
+ public static T Count < T > ( T value )
57
+ {
58
+ return value ;
59
+ }
60
+
61
+ public static string Count ( string value )
62
+ {
63
+ return "COUNT({0})" . Fmt ( value ) ;
64
+ }
65
+
66
+ public static T Min < T > ( T value )
67
+ {
68
+ return value ;
69
+ }
70
+
71
+ public static string Min ( string value )
72
+ {
73
+ return "MIN({0})" . Fmt ( value ) ;
74
+ }
75
+
76
+ public static T Max < T > ( T value )
77
+ {
78
+ return value ;
79
+ }
80
+
81
+ public static string Max ( string value )
82
+ {
83
+ return "MAX({0})" . Fmt ( value ) ;
84
+ }
85
+
86
+ public static T Avg < T > ( T value )
87
+ {
88
+ return value ;
89
+ }
90
+
91
+ public static string Avg ( string value )
92
+ {
93
+ return "AVG({0})" . Fmt ( value ) ;
94
+ }
95
+ }
96
+
97
+ }
98
+
0 commit comments