@@ -31,13 +31,13 @@ namespace PetaPoco
3131{
3232 public static class DatabaseExtensions
3333 {
34- private static Sql ToSql < T > ( this Expression < Func < T , bool > > query , Database db )
34+ private static Sql ToSql < T > ( this Expression < Func < T , bool > > query , IDatabase db )
3535 {
3636 var translated = ExpressionToSql . Translate ( new DatabaseQuoter ( db ) , query ) ;
3737 return new Sql ( translated . Item1 , translated . Item2 ) ;
3838 }
3939
40- private static Sql ToSql < T > ( this FSharpExpr < FSharpFunc < T , bool > > query , Database db )
40+ private static Sql ToSql < T > ( this FSharpExpr < FSharpFunc < T , bool > > query , IDatabase db )
4141 {
4242 var translated = ExpressionToSql . Translate ( new DatabaseQuoter ( db ) , query ) ;
4343 return new Sql ( translated . Item1 , translated . Item2 ) ;
@@ -51,7 +51,7 @@ private static Sql ToSql<T>(this FSharpExpr<FSharpFunc<T, bool>> query, Database
5151 /// <typeparam name="T">The Type representing a row in the result set</typeparam>
5252 /// <param name="query">An Expression describing the records to be retrieved."/> </param>
5353 /// <returns>A List holding the results of the query</returns>
54- public static List < T > Fetch < T > ( this Database db , Expression < Func < T , bool > > query )
54+ public static List < T > Fetch < T > ( this IDatabase db , Expression < Func < T , bool > > query )
5555 => db . Fetch < T > ( query . ToSql ( db ) ) ;
5656
5757 /// <summary>
@@ -67,7 +67,7 @@ public static List<T> Fetch<T>(this Database db, Expression<Func<T, bool>> query
6767 /// records for the specified page. It will also execute a second query to retrieve the
6868 /// total number of records in the result set.
6969 /// </remarks>
70- public static Page < T > Page < T > ( this Database db , long page , long itemsPerPage , Expression < Func < T , bool > > query )
70+ public static Page < T > Page < T > ( this IDatabase db , long page , long itemsPerPage , Expression < Func < T , bool > > query )
7171 => db . Page < T > ( page , itemsPerPage , query . ToSql ( db ) ) ;
7272
7373 /// <summary>
@@ -82,7 +82,7 @@ public static Page<T> Page<T>(this Database db, long page, long itemsPerPage, Ex
8282 /// PetaPoco will automatically modify the supplied SELECT statement to only retrieve the
8383 /// records for the specified page.
8484 /// </remarks>
85- public static List < T > Fetch < T > ( this Database db , long page , long itemsPerPage , Expression < Func < T , bool > > query )
85+ public static List < T > Fetch < T > ( this IDatabase db , long page , long itemsPerPage , Expression < Func < T , bool > > query )
8686 => db . Fetch < T > ( page , itemsPerPage , query . ToSql ( db ) ) ;
8787
8888 /// <summary>
@@ -97,7 +97,7 @@ public static List<T> Fetch<T>(this Database db, long page, long itemsPerPage, E
9797 /// PetaPoco will automatically modify the supplied SELECT statement to only retrieve the
9898 /// records for the specified range.
9999 /// </remarks>
100- public static List < T > SkipTake < T > ( this Database db , long skip , long take , Expression < Func < T , bool > > query )
100+ public static List < T > SkipTake < T > ( this IDatabase db , long skip , long take , Expression < Func < T , bool > > query )
101101 => db . SkipTake < T > ( skip , take , query . ToSql ( db ) ) ;
102102
103103 /// <summary>
@@ -111,7 +111,7 @@ public static List<T> SkipTake<T>(this Database db, long skip, long take, Expres
111111 /// and disposing the previous one. In cases where this is an issue, consider using Fetch which
112112 /// returns the results as a List rather than an IEnumerable.
113113 /// </remarks>
114- public static IEnumerable < T > Query < T > ( this Database db , Expression < Func < T , bool > > query )
114+ public static IEnumerable < T > Query < T > ( this IDatabase db , Expression < Func < T , bool > > query )
115115 => db . Query < T > ( query . ToSql ( db ) ) ;
116116
117117 /// <summary>
@@ -123,7 +123,7 @@ public static IEnumerable<T> Query<T>(this Database db, Expression<Func<T, bool>
123123 /// <remarks>
124124 /// Throws an exception if there are zero or more than one matching record
125125 /// </remarks>
126- public static T Single < T > ( this Database db , Expression < Func < T , bool > > query )
126+ public static T Single < T > ( this IDatabase db , Expression < Func < T , bool > > query )
127127 => db . Single < T > ( query . ToSql ( db ) ) ;
128128
129129 /// <summary>
@@ -132,7 +132,7 @@ public static T Single<T>(this Database db, Expression<Func<T, bool>> query)
132132 /// <typeparam name="T">The Type representing a row in the result set</typeparam>
133133 /// <param name="query">An Expression describing the record to be retrieved."/> </param>
134134 /// <returns>The single record matching the specified condition, or default(T) if no matching rows</returns>
135- public static T SingleOrDefault < T > ( this Database db , Expression < Func < T , bool > > query )
135+ public static T SingleOrDefault < T > ( this IDatabase db , Expression < Func < T , bool > > query )
136136 => db . SingleOrDefault < T > ( query . ToSql ( db ) ) ;
137137
138138 /// <summary>
@@ -141,7 +141,7 @@ public static T SingleOrDefault<T>(this Database db, Expression<Func<T, bool>> q
141141 /// <typeparam name="T">The Type representing a row in the result set</typeparam>
142142 /// <param name="query">An Expression describing the records to be retrieved."/> </param>
143143 /// <returns>The first record in the result set</returns>
144- public static T First < T > ( this Database db , Expression < Func < T , bool > > query )
144+ public static T First < T > ( this IDatabase db , Expression < Func < T , bool > > query )
145145 => db . First < T > ( query . ToSql ( db ) ) ;
146146
147147 /// <summary>
@@ -150,7 +150,7 @@ public static T First<T>(this Database db, Expression<Func<T, bool>> query)
150150 /// <typeparam name="T">The Type representing a row in the result set</typeparam>
151151 /// <param name="query">An Expression describing the records to be retrieved."/> </param>
152152 /// <returns>The first record in the result set, or default(T) if no matching rows</returns>
153- public static T FirstOrDefault < T > ( this Database db , Expression < Func < T , bool > > query )
153+ public static T FirstOrDefault < T > ( this IDatabase db , Expression < Func < T , bool > > query )
154154 => db . FirstOrDefault < T > ( query . ToSql ( db ) ) ;
155155
156156 /// <summary>
@@ -162,7 +162,7 @@ public static T FirstOrDefault<T>(this Database db, Expression<Func<T, bool>> qu
162162 /// everything after "DELETE FROM tablename"
163163 /// </param>
164164 /// <returns>The number of affected rows</returns>
165- public static int Delete < T > ( this Database db , Expression < Func < T , bool > > query )
165+ public static int Delete < T > ( this IDatabase db , Expression < Func < T , bool > > query )
166166 => db . Delete < T > ( query . ToSql ( db ) ) ;
167167 #endregion
168168
@@ -173,7 +173,7 @@ public static int Delete<T>(this Database db, Expression<Func<T, bool>> query)
173173 /// <typeparam name="T">The Type representing a row in the result set</typeparam>
174174 /// <param name="query">An Expression describing the records to be retrieved."/> </param>
175175 /// <returns>A List holding the results of the query</returns>
176- public static List < T > Fetch < T > ( this Database db , FSharpExpr < FSharpFunc < T , bool > > query )
176+ public static List < T > Fetch < T > ( this IDatabase db , FSharpExpr < FSharpFunc < T , bool > > query )
177177 => db . Fetch < T > ( query . ToSql ( db ) ) ;
178178
179179 /// <summary>
@@ -189,7 +189,7 @@ public static List<T> Fetch<T>(this Database db, FSharpExpr<FSharpFunc<T, bool>>
189189 /// records for the specified page. It will also execute a second query to retrieve the
190190 /// total number of records in the result set.
191191 /// </remarks>
192- public static Page < T > Page < T > ( this Database db , long page , long itemsPerPage , FSharpExpr < FSharpFunc < T , bool > > query )
192+ public static Page < T > Page < T > ( this IDatabase db , long page , long itemsPerPage , FSharpExpr < FSharpFunc < T , bool > > query )
193193 => db . Page < T > ( page , itemsPerPage , query . ToSql ( db ) ) ;
194194
195195 /// <summary>
@@ -204,7 +204,7 @@ public static Page<T> Page<T>(this Database db, long page, long itemsPerPage, FS
204204 /// PetaPoco will automatically modify the supplied SELECT statement to only retrieve the
205205 /// records for the specified page.
206206 /// </remarks>
207- public static List < T > Fetch < T > ( this Database db , long page , long itemsPerPage , FSharpExpr < FSharpFunc < T , bool > > query )
207+ public static List < T > Fetch < T > ( this IDatabase db , long page , long itemsPerPage , FSharpExpr < FSharpFunc < T , bool > > query )
208208 => db . Fetch < T > ( page , itemsPerPage , query . ToSql ( db ) ) ;
209209
210210 /// <summary>
@@ -219,7 +219,7 @@ public static List<T> Fetch<T>(this Database db, long page, long itemsPerPage, F
219219 /// PetaPoco will automatically modify the supplied SELECT statement to only retrieve the
220220 /// records for the specified range.
221221 /// </remarks>
222- public static List < T > SkipTake < T > ( this Database db , long skip , long take , FSharpExpr < FSharpFunc < T , bool > > query )
222+ public static List < T > SkipTake < T > ( this IDatabase db , long skip , long take , FSharpExpr < FSharpFunc < T , bool > > query )
223223 => db . SkipTake < T > ( skip , take , query . ToSql ( db ) ) ;
224224
225225 /// <summary>
@@ -233,7 +233,7 @@ public static List<T> SkipTake<T>(this Database db, long skip, long take, FSharp
233233 /// and disposing the previous one. In cases where this is an issue, consider using Fetch which
234234 /// returns the results as a List rather than an IEnumerable.
235235 /// </remarks>
236- public static IEnumerable < T > Query < T > ( this Database db , FSharpExpr < FSharpFunc < T , bool > > query )
236+ public static IEnumerable < T > Query < T > ( this IDatabase db , FSharpExpr < FSharpFunc < T , bool > > query )
237237 => db . Query < T > ( query . ToSql ( db ) ) ;
238238
239239 /// <summary>
@@ -245,7 +245,7 @@ public static IEnumerable<T> Query<T>(this Database db, FSharpExpr<FSharpFunc<T,
245245 /// <remarks>
246246 /// Throws an exception if there are zero or more than one matching record
247247 /// </remarks>
248- public static T Single < T > ( this Database db , FSharpExpr < FSharpFunc < T , bool > > query )
248+ public static T Single < T > ( this IDatabase db , FSharpExpr < FSharpFunc < T , bool > > query )
249249 => db . Single < T > ( query . ToSql ( db ) ) ;
250250
251251 /// <summary>
@@ -254,7 +254,7 @@ public static T Single<T>(this Database db, FSharpExpr<FSharpFunc<T, bool>> quer
254254 /// <typeparam name="T">The Type representing a row in the result set</typeparam>
255255 /// <param name="query">An Expression describing the record to be retrieved."/> </param>
256256 /// <returns>The single record matching the specified condition, or default(T) if no matching rows</returns>
257- public static T SingleOrDefault < T > ( this Database db , FSharpExpr < FSharpFunc < T , bool > > query )
257+ public static T SingleOrDefault < T > ( this IDatabase db , FSharpExpr < FSharpFunc < T , bool > > query )
258258 => db . SingleOrDefault < T > ( query . ToSql ( db ) ) ;
259259
260260 /// <summary>
@@ -263,7 +263,7 @@ public static T SingleOrDefault<T>(this Database db, FSharpExpr<FSharpFunc<T, bo
263263 /// <typeparam name="T">The Type representing a row in the result set</typeparam>
264264 /// <param name="query">An Expression describing the records to be retrieved."/> </param>
265265 /// <returns>The first record in the result set</returns>
266- public static T First < T > ( this Database db , FSharpExpr < FSharpFunc < T , bool > > query )
266+ public static T First < T > ( this IDatabase db , FSharpExpr < FSharpFunc < T , bool > > query )
267267 => db . First < T > ( query . ToSql ( db ) ) ;
268268
269269 /// <summary>
@@ -272,7 +272,7 @@ public static T First<T>(this Database db, FSharpExpr<FSharpFunc<T, bool>> query
272272 /// <typeparam name="T">The Type representing a row in the result set</typeparam>
273273 /// <param name="query">An Expression describing the records to be retrieved."/> </param>
274274 /// <returns>The first record in the result set, or default(T) if no matching rows</returns>
275- public static T FirstOrDefault < T > ( this Database db , FSharpExpr < FSharpFunc < T , bool > > query )
275+ public static T FirstOrDefault < T > ( this IDatabase db , FSharpExpr < FSharpFunc < T , bool > > query )
276276 => db . FirstOrDefault < T > ( query . ToSql ( db ) ) ;
277277
278278 /// <summary>
@@ -284,7 +284,7 @@ public static T FirstOrDefault<T>(this Database db, FSharpExpr<FSharpFunc<T, boo
284284 /// everything after "DELETE FROM tablename"
285285 /// </param>
286286 /// <returns>The number of affected rows</returns>
287- public static int Delete < T > ( this Database db , FSharpExpr < FSharpFunc < T , bool > > query )
287+ public static int Delete < T > ( this IDatabase db , FSharpExpr < FSharpFunc < T , bool > > query )
288288 => db . Delete < T > ( query . ToSql ( db ) ) ;
289289 #endregion
290290 }
0 commit comments