1
1
using System ;
2
2
using System . Linq ;
3
3
using System . Linq . Expressions ;
4
+ using NHibernate . Dialect ;
4
5
using NHibernate . Linq ;
5
6
using NHibernate . DomainModel . Northwind . Entities ;
6
7
using NUnit . Framework ;
@@ -92,8 +93,8 @@ where p.ProductId > 1
92
93
orderby p . ProductId
93
94
select p ;
94
95
95
- // ToList required otherwise the First call alters the paging and test something else than paging three pages.
96
- // (And Skip().Take().First() causes a bug with Oracle.)
96
+ // ToList required otherwise the First call alters the paging and test something else than paging three pages,
97
+ // contrary o the test above description.
97
98
var page2 = q . Skip ( 5 ) . Take ( 5 ) . ToList ( ) ;
98
99
var page3 = q . Skip ( 10 ) . Take ( 5 ) . ToList ( ) ;
99
100
var page4 = q . Skip ( 15 ) . Take ( 5 ) . ToList ( ) ;
@@ -107,7 +108,30 @@ orderby p.ProductId
107
108
Assert . AreNotEqual ( firstResultOnPage2 . ProductId , firstResultOnPage4 . ProductId ) ;
108
109
}
109
110
110
- [ Test ]
111
+ [ Category ( "Paging" ) ]
112
+ [ Test ( Description = "NH-4061 - This sample uses a where clause and the Skip and Take operators to select " +
113
+ "the second, third and fourth pages of products, but then add a First causing the Take to be pointless." ) ]
114
+ public void TriplePageSelectionWithFirst ( )
115
+ {
116
+ if ( Dialect is Oracle8iDialect )
117
+ Assert . Ignore ( "Not fixed: NH-4061 - Pointless Take calls screw Oracle dialect paging." ) ;
118
+
119
+ var q =
120
+ from p in db . Products
121
+ where p . ProductId > 1
122
+ orderby p . ProductId
123
+ select p ;
124
+
125
+ var firstResultOnPage2 = q . Skip ( 5 ) . Take ( 5 ) . First ( ) ;
126
+ var firstResultOnPage3 = q . Skip ( 10 ) . Take ( 5 ) . First ( ) ;
127
+ var firstResultOnPage4 = q . Skip ( 15 ) . Take ( 5 ) . First ( ) ;
128
+
129
+ Assert . AreNotEqual ( firstResultOnPage2 . ProductId , firstResultOnPage3 . ProductId ) ;
130
+ Assert . AreNotEqual ( firstResultOnPage3 . ProductId , firstResultOnPage4 . ProductId ) ;
131
+ Assert . AreNotEqual ( firstResultOnPage2 . ProductId , firstResultOnPage4 . ProductId ) ;
132
+ }
133
+
134
+ [ Test ]
111
135
public void SelectFromObject ( )
112
136
{
113
137
using ( var s = OpenSession ( ) )
0 commit comments