@@ -36,7 +36,7 @@ public void API_SqlServer_Examples()
36
36
db . Select < Person > ( q => q . Where ( x => x . Age > 40 ) ) ;
37
37
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT \" Id\" , \" FirstName\" , \" LastName\" , \" Age\" \n FROM \" Person\" \n WHERE (\" Age\" > 40)" ) ) ;
38
38
39
- db . Select ( db . SqlExpression < Person > ( ) . Where ( x => x . Age > 40 ) ) ;
39
+ db . Select ( db . From < Person > ( ) . Where ( x => x . Age > 40 ) ) ;
40
40
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT \" Id\" , \" FirstName\" , \" LastName\" , \" Age\" \n FROM \" Person\" \n WHERE (\" Age\" > 40)" ) ) ;
41
41
42
42
db . Single < Person > ( x => x . Age == 42 ) ;
@@ -45,7 +45,7 @@ public void API_SqlServer_Examples()
45
45
db . Single < Person > ( q => q . Where ( x => x . Age == 42 ) ) ;
46
46
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT TOP 1 \" Id\" , \" FirstName\" , \" LastName\" , \" Age\" \n FROM \" Person\" \n WHERE (\" Age\" = 42)" ) ) ;
47
47
48
- db . Single ( db . SqlExpression < Person > ( ) . Where ( x => x . Age == 42 ) ) ;
48
+ db . Single ( db . From < Person > ( ) . Where ( x => x . Age == 42 ) ) ;
49
49
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT TOP 1 \" Id\" , \" FirstName\" , \" LastName\" , \" Age\" \n FROM \" Person\" \n WHERE (\" Age\" = 42)" ) ) ;
50
50
51
51
db . Scalar < Person , int > ( x => Sql . Max ( x . Age ) ) ;
@@ -57,7 +57,7 @@ public void API_SqlServer_Examples()
57
57
db . Count < Person > ( x => x . Age < 50 ) ;
58
58
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT COUNT(*) FROM \" Person\" WHERE (\" Age\" < 50)" ) ) ;
59
59
60
- db . Count ( db . SqlExpression < Person > ( ) . Where ( x => x . Age < 50 ) ) ;
60
+ db . Count ( db . From < Person > ( ) . Where ( x => x . Age < 50 ) ) ;
61
61
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT COUNT(*) FROM \" Person\" WHERE (\" Age\" < 50)" ) ) ;
62
62
63
63
@@ -133,30 +133,47 @@ public void API_SqlServer_Examples()
133
133
db . SingleWhere < Person > ( "Age" , 42 ) ;
134
134
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT \" Id\" , \" FirstName\" , \" LastName\" , \" Age\" FROM \" Person\" WHERE \" Age\" = @Age" ) ) ;
135
135
136
+ db . Scalar < int > ( db . From < Person > ( ) . Select ( Sql . Count ( "*" ) ) . Where ( q => q . Age > 40 ) ) ;
137
+ Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT COUNT(*) \n FROM \" Person\" \n WHERE (\" Age\" > 40)" ) ) ;
138
+ db . Scalar < int > ( db . From < Person > ( ) . Select ( x => Sql . Count ( "*" ) ) . Where ( q => q . Age > 40 ) ) ;
139
+ Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT Count(*) \n FROM \" Person\" \n WHERE (\" Age\" > 40)" ) ) ;
140
+
136
141
db . Scalar < int > ( "SELECT COUNT(*) FROM Person WHERE Age > @age" , new { age = 40 } ) ;
137
142
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT COUNT(*) FROM Person WHERE Age > @age" ) ) ;
138
143
139
144
db . ScalarFmt < int > ( "SELECT COUNT(*) FROM Person WHERE Age > {0}" , 40 ) ;
140
145
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT COUNT(*) FROM Person WHERE Age > 40" ) ) ;
141
146
147
+ db . Column < string > ( db . From < Person > ( ) . Select ( x => x . LastName ) . Where ( q => q . Age == 27 ) ) ;
148
+ Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT \" LastName\" \n FROM \" Person\" \n WHERE (\" Age\" = 27)" ) ) ;
149
+
142
150
db . Column < string > ( "SELECT LastName FROM Person WHERE Age = @age" , new { age = 27 } ) ;
143
151
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT LastName FROM Person WHERE Age = @age" ) ) ;
144
152
145
153
db . ColumnFmt < string > ( "SELECT LastName FROM Person WHERE Age = {0}" , 27 ) ;
146
154
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT LastName FROM Person WHERE Age = 27" ) ) ;
147
155
156
+ db . ColumnDistinct < int > ( db . From < Person > ( ) . Select ( x => x . Age ) . Where ( q => q . Age < 50 ) ) ;
157
+ Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT \" Age\" \n FROM \" Person\" \n WHERE (\" Age\" < 50)" ) ) ;
158
+
148
159
db . ColumnDistinct < int > ( "SELECT Age FROM Person WHERE Age < @age" , new { age = 50 } ) ;
149
160
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT Age FROM Person WHERE Age < @age" ) ) ;
150
161
151
162
db . ColumnDistinctFmt < int > ( "SELECT Age FROM Person WHERE Age < {0}" , 50 ) ;
152
163
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT Age FROM Person WHERE Age < 50" ) ) ;
153
164
165
+ db . Lookup < int , string > ( db . From < Person > ( ) . Select ( x => new { x . Age , x . LastName } ) . Where ( q => q . Age < 50 ) ) ;
166
+ Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT \" Age\" ,\" LastName\" \n FROM \" Person\" \n WHERE (\" Age\" < 50)" ) ) ;
167
+
154
168
db . Lookup < int , string > ( "SELECT Age, LastName FROM Person WHERE Age < @age" , new { age = 50 } ) ;
155
169
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT Age, LastName FROM Person WHERE Age < @age" ) ) ;
156
170
157
171
db . LookupFmt < int , string > ( "SELECT Age, LastName FROM Person WHERE Age < {0}" , 50 ) ;
158
172
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT Age, LastName FROM Person WHERE Age < 50" ) ) ;
159
173
174
+ db . Dictionary < int , string > ( db . From < Person > ( ) . Select ( x => new { x . Id , x . LastName } ) . Where ( x => x . Age < 50 ) ) ;
175
+ Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT \" Id\" ,\" LastName\" \n FROM \" Person\" \n WHERE (\" Age\" < 50)" ) ) ;
176
+
160
177
db . Dictionary < int , string > ( "SELECT Id, LastName FROM Person WHERE Age < @age" , new { age = 50 } ) ;
161
178
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT Id, LastName FROM Person WHERE Age < @age" ) ) ;
162
179
@@ -166,7 +183,7 @@ public void API_SqlServer_Examples()
166
183
db . Exists < Person > ( x => x . Age < 50 ) ;
167
184
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT COUNT(*) FROM \" Person\" WHERE (\" Age\" < 50)" ) ) ;
168
185
169
- db . Exists ( db . SqlExpression < Person > ( ) . Where ( x => x . Age < 50 ) ) ;
186
+ db . Exists ( db . From < Person > ( ) . Where ( x => x . Age < 50 ) ) ;
170
187
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT COUNT(*) FROM \" Person\" WHERE (\" Age\" < 50)" ) ) ;
171
188
172
189
db . Exists < Person > ( new { Age = 42 } ) ;
@@ -182,18 +199,27 @@ public void API_SqlServer_Examples()
182
199
db . ExistsFmt < Person > ( "SELECT * FROM Person WHERE Age = {0}" , 42 ) ;
183
200
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT * FROM Person WHERE Age = 42" ) ) ;
184
201
202
+ db . SqlList < Person > ( db . From < Person > ( ) . Select ( "*" ) . Where ( q => q . Age < 50 ) ) ;
203
+ Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT * \n FROM \" Person\" \n WHERE (\" Age\" < 50)" ) ) ;
204
+
185
205
db . SqlList < Person > ( "SELECT * FROM Person WHERE Age < @age" , new { age = 50 } ) ;
186
206
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT * FROM Person WHERE Age < @age" ) ) ;
187
207
188
208
db . SqlList < Person > ( "SELECT * FROM Person WHERE Age < @age" , new Dictionary < string , object > { { "age" , 50 } } ) ;
189
209
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT * FROM Person WHERE Age < @age" ) ) ;
190
210
211
+ db . SqlColumn < string > ( db . From < Person > ( ) . Select ( x => x . LastName ) . Where ( q => q . Age < 50 ) ) ;
212
+ Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT \" LastName\" \n FROM \" Person\" \n WHERE (\" Age\" < 50)" ) ) ;
213
+
191
214
db . SqlColumn < string > ( "SELECT LastName FROM Person WHERE Age < @age" , new { age = 50 } ) ;
192
215
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT LastName FROM Person WHERE Age < @age" ) ) ;
193
216
194
217
db . SqlColumn < string > ( "SELECT LastName FROM Person WHERE Age < @age" , new Dictionary < string , object > { { "age" , 50 } } ) ;
195
218
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT LastName FROM Person WHERE Age < @age" ) ) ;
196
219
220
+ db . SqlScalar < int > ( db . From < Person > ( ) . Select ( Sql . Count ( "*" ) ) . Where ( q => q . Age < 50 ) ) ;
221
+ Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT COUNT(*) \n FROM \" Person\" \n WHERE (\" Age\" < 50)" ) ) ;
222
+
197
223
db . SqlScalar < int > ( "SELECT COUNT(*) FROM Person WHERE Age < @age" , new { age = 50 } ) ;
198
224
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "SELECT COUNT(*) FROM Person WHERE Age < @age" ) ) ;
199
225
@@ -222,7 +248,7 @@ public void API_SqlServer_Examples()
222
248
db . InsertOnly ( new PersonWithAutoId { FirstName = "Amy" , Age = 27 } , ev => ev . Insert ( p => new { p . FirstName , p . Age } ) ) ;
223
249
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "INSERT INTO \" PersonWithAutoId\" (\" FirstName\" ,\" Age\" ) VALUES ('Amy',27)" ) ) ;
224
250
225
- db . InsertOnly ( new PersonWithAutoId { FirstName = "Amy" , Age = 27 } , ev => db . SqlExpression < PersonWithAutoId > ( ) . Insert ( p => new { p . FirstName , p . Age } ) ) ;
251
+ db . InsertOnly ( new PersonWithAutoId { FirstName = "Amy" , Age = 27 } , ev => db . From < PersonWithAutoId > ( ) . Insert ( p => new { p . FirstName , p . Age } ) ) ;
226
252
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "INSERT INTO \" PersonWithAutoId\" (\" FirstName\" ,\" Age\" ) VALUES ('Amy',27)" ) ) ;
227
253
228
254
db . Update ( new Person { Id = 1 , FirstName = "Jimi" , LastName = "Hendrix" , Age = 27 } ) ;
@@ -301,7 +327,7 @@ public void API_SqlServer_Examples()
301
327
db . Delete < Person > ( ev => ev . Where ( p => p . Age == 27 ) ) ;
302
328
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "DELETE FROM \" Person\" WHERE (\" Age\" = 27)" ) ) ;
303
329
304
- db . Delete ( db . SqlExpression < Person > ( ) . Where ( p => p . Age == 27 ) ) ;
330
+ db . Delete ( db . From < Person > ( ) . Where ( p => p . Age == 27 ) ) ;
305
331
Assert . That ( db . GetLastSql ( ) , Is . EqualTo ( "DELETE FROM \" Person\" WHERE (\" Age\" = 27)" ) ) ;
306
332
307
333
db . DeleteFmt < Person > ( where : "Age = {0}" . SqlFmt ( 27 ) ) ;
0 commit comments