private string ResolveQuery(string criteria, string orderBy, int page = 0) { int startRecord = (page * RecordsPerPage) + 1; int endRecord = (page * RecordsPerPage) + RecordsPerPage; string result = DefaultQuery; if (!string.IsNullOrEmpty(criteria)) { result += $" WHERE {criteria}"; } return($"WITH [source] AS ({SqlServerDb.InsertRowNumberColumn(result, orderBy)}) SELECT * FROM [source] WHERE [RowNumber] BETWEEN {startRecord} AND {endRecord};"); }
public SqlServerRowManager(SqlServerDb db) { _db = db; SqlServerGenerator <TRecord, TKey> sg = new SqlServerGenerator <TRecord, TKey>(); FindCommand = sg.FindStatement(); DefaultQuery = sg.SelectStatement(); if (IsMapped()) { InsertCommand = sg.InsertStatement(); UpdateCommand = sg.UpdateStatement(); DeleteCommand = sg.DeleteStatement(); } }
public SqlServerQuery(string sql, SqlServerDb db) : base(sql, db) { }
public ProfilerWrapper(SqlServerDb db, IDbConnection connection, CommandDefinition cmdDef) { _cn = connection; _profiler = db.Profiler; _profiler?.Start(connection, cmdDef); }