Пример #1
0
        public void METHODNAME()
        {
            SqlServerDialect dialect = new SqlServerDialect();
            string           sql     = dialect.GetPagingSql("SELECT [client].[Individual].[FirstName], [client].[Individual].[LastName] AS [Last] FROM [client].[Individual] ORDER BY [client].[Individual].[LastName], [client].[Individual].[FirstName]", 1, 10, new Dictionary <string, object>());

            sql = dialect.GetPagingSql("SELECT [client].[Individual].[FirstName], [client].[Individual].[LastName] AS [Last] FROM [client].[Individual]", 1, 10, new Dictionary <string, object>());
        }
        public void GetPagingSql()
        {
            var dialect    = new SqlServerDialect();
            var dictionary = new Dictionary <string, object>();
            var query      = dialect.GetPagingSql("select distinct name as first_name from TestEntity order by id where id > 2", 2, 10, dictionary);

            Assert.Equal("SELECT TOP(10) [_proj].[first_name] FROM (select distinct ROW_NUMBER() OVER(ORDER BY id) AS [_row_number], name as first_name from TestEntity where id > 2) [_proj] " +
                         "WHERE [_proj].[_row_number] >= @_pageStartRow ORDER BY [_proj].[_row_number]", query);

            Assert.Equal(20, dictionary["@_pageStartRow"]);

            dictionary = new Dictionary <string, object>();
            query      = dialect.GetPagingSql("select id, name from TestEntity order by id", 2, 10, dictionary);
            Assert.Equal("SELECT TOP(10) [_proj].[id], [_proj].[name] FROM (select ROW_NUMBER() OVER(ORDER BY id) AS [_row_number], id, name from TestEntity) [_proj] " +
                         "WHERE [_proj].[_row_number] >= @_pageStartRow ORDER BY [_proj].[_row_number]", query);
        }