1
1
using System ;
2
+ using System . Collections . Generic ;
2
3
using System . Data ;
3
4
using System . Data . Common ;
5
+ using System . Data . OleDb ;
6
+ using System . Text . RegularExpressions ;
4
7
using NHibernate . Dialect . Function ;
5
8
using NHibernate . Dialect . Schema ;
6
9
using NHibernate . JetDriver . Schema ;
@@ -212,9 +215,9 @@ public override bool SupportsVariableLimit
212
215
/// <returns>Processed query</returns>
213
216
public override SqlString GetLimitString ( SqlString queryString , SqlString offset , SqlString limit )
214
217
{
215
- // int insertIndex = GetAfterSelectInsertPoint(queryString);
216
- //
217
- // var builder = new SqlStringBuilder(queryString);
218
+ // int insertIndex = GetAfterSelectInsertPoint(queryString);
219
+ //
220
+ // var builder = new SqlStringBuilder(queryString);
218
221
219
222
/*
220
223
* Where 15 is the StartPos + PageSize, and 5 is the PageSize. https://stackoverflow.com/a/1900668/100863
@@ -233,9 +236,18 @@ ORDER BY subOrdered.`SMP_GLOBALID`
233
236
builder.
234
237
*/
235
238
236
- var lim = limit . ToString ( ) ;
237
- var result = queryString . Replace ( "SELECT" , string . Format ( "SELECT TOP {0}" , limit ) ) ;
238
- return result ;
239
+ // var returnList = new List<string>();
240
+ //
241
+ // DataTable dt = _jetDbConnection.Connection.GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys, new Object[] { null, null, "Employee" });
242
+ // int columnOrdinalForName = dt.Columns["COLUMN_NAME"].Ordinal;
243
+ //
244
+ // foreach (DataRow r in dt.Rows)
245
+ // {
246
+ // returnList.Add(r.ItemArray[columnOrdinalForName].ToString());
247
+ // }
248
+
249
+ var result = Regex . Replace ( queryString . ToString ( ) , "SELECT" , $ "SELECT TOP { limit } ", RegexOptions . IgnoreCase ) ;
250
+ return new SqlString ( result ) ;
239
251
}
240
252
241
253
@@ -268,10 +280,11 @@ public override string UnQuote(string quoted)
268
280
return quoted . Replace ( new string ( CloseQuote , 2 ) , CloseQuote . ToString ( ) ) ;
269
281
}
270
282
283
+ private JetDbConnection _jetDbConnection ;
271
284
public override IDataBaseSchema GetDataBaseSchema ( DbConnection connection )
272
285
{
273
- var jetConnection = ( JetDbConnection ) connection ;
274
- return new JetDataBaseSchema ( jetConnection . Connection ) ;
286
+ _jetDbConnection = ( JetDbConnection ) connection ;
287
+ return new JetDataBaseSchema ( _jetDbConnection . Connection ) ;
275
288
}
276
289
277
290
public override JoinFragment CreateOuterJoinFragment ( )
0 commit comments