예제 #1
0
        /// <summary>
        /// Execute for pagination
        /// </summary>
        static void ExecutePaginated(IExecutor executor, bool canDisplayRowNumber = true)
        {
            // create parameter object instance for 2-way-sql
            var condition = new SqlCondition
            {
                BirthDateFrom = new DateTime(1980, 1, 1),
                BirthDateTo   = new DateTime(1990, 1, 1)
            };
            var watch = new Stopwatch();

            watch.Start();
            // create SqlParse instance
            var parser = new SqlParser(FilePath, condition);



            // parse paginated
            string rowNumberColumn = null;

            if (canDisplayRowNumber)
            {
                rowNumberColumn = "SerialNumber";
            }
            var result = parser.ParsePaginated(5, 10, rowNumberColumn);

            watch.Stop();
            Console.WriteLine($"time\t{watch.Elapsed}");

            watch.Reset();

            watch.Start();
            Debug.WriteLine($"+++>{result.Result.DebugSql}");
            Debug.WriteLine($"+++>{result.CountResult.DebugSql}");

            executor.ExecutePaginated(ConnectionString, result.Result, canDisplayRowNumber);
            executor.ExecuteCount(ConnectionString, result.CountResult);
            watch.Stop();
            Console.WriteLine($"time\t{watch.Elapsed}");

            result = parser.ParsePaginated(15, 10, rowNumberColumn);
            watch.Reset();

            watch.Start();
            Debug.WriteLine($"+++>{result.Result.DebugSql}");
            Debug.WriteLine($"+++>{result.CountResult.DebugSql}");
            executor.ExecutePaginated(ConnectionString, result.Result, canDisplayRowNumber);
            executor.ExecuteCount(ConnectionString, result.CountResult);
            watch.Stop();
            Console.WriteLine($"time\t{watch.Elapsed}");
        }