public void ShouldApplyLimitUsingTop()
        {
            var sql = "select a,b,c from d where a = 1 order by c";
            var expected = new[] { "select top(5) a,b,c from d where a = 1 order by c" };

            var pagedSql = new SqlCe40QueryPager().ApplyLimit(sql, 5);
            var modified = pagedSql.Select(x => Normalize.Replace(x, " ").ToLowerInvariant());

            Assert.IsTrue(expected.SequenceEqual(modified));
        }
        public void ShouldApplyPagingUsingOrderByFirstColumnIfNotAlreadyOrdered()
        {
            var sql = "select a,b,c from d where a = 1";
            var expected = new[]{
                "select a,b,c from d where a = 1 order by a offset 10 rows fetch next 20 rows only"};

            var pagedSql = new SqlCe40QueryPager().ApplyPaging(sql, new string[0], 10, 20);
            var modified = pagedSql.Select(x => Normalize.Replace(x, " ").ToLowerInvariant());

            Assert.IsTrue(expected.SequenceEqual(modified));
        }
예제 #3
0
        public void ShouldApplyPagingUsingOrderBy()
        {
            var sql = "select a,b,c from d where a = 1 order by c";
            var expected = new[]{
                "select a,b,c from d where a = 1 order by c offset 5 rows fetch next 10 rows only"};

            var pagedSql = new SqlCe40QueryPager().ApplyPaging(sql, 5, 10);
            var modified = pagedSql.Select(x=> Normalize.Replace(x, " ").ToLowerInvariant());

            Assert.IsTrue(expected.SequenceEqual(modified));
        }