コード例 #1
0
        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));
        }
コード例 #2
0
        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, 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, new string[0], 5, 10);
            var modified = pagedSql.Select(x => Normalize.Replace(x, " ").ToLowerInvariant());

            Assert.IsTrue(expected.SequenceEqual(modified));
        }
コード例 #4
0
        public void ShouldApplyPagingUsingOrderByFirstColumnIfNotAlreadyOrdered()
        {
            const string sql      = "select a,b,c from d where a = 1";
            const string expected =
                "select a,b,c from d where a = 1 order by a offset @skip rows fetch next @take rows only";

            var modified = new SqlCe40QueryPager().ApplyPaging(sql, "@skip", "@take");

            modified = Normalize.Replace(modified, " ").ToLowerInvariant();

            Assert.AreEqual(expected, modified);
        }