Beispiel #1
0
        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};");
        }
Beispiel #2
0
        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();
            }
        }
Beispiel #3
0
 public SqlServerQuery(string sql, SqlServerDb db) : base(sql, db)
 {
 }
Beispiel #4
0
 public ProfilerWrapper(SqlServerDb db, IDbConnection connection, CommandDefinition cmdDef)
 {
     _cn       = connection;
     _profiler = db.Profiler;
     _profiler?.Start(connection, cmdDef);
 }