1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.ActiveRecord
.Queries
.Modifiers
20 /// Limits a query to the specified results.
22 public class QueryRange
: IQueryModifier
24 private readonly int firstResult
;
25 private readonly int maxResults
;
28 /// Initializes a new instance of the <see cref="QueryRange"/> class.
30 /// <param name="firstResult">The first result.</param>
31 /// <param name="maxResults">The max results.</param>
32 public QueryRange(int firstResult
, int maxResults
)
34 this.firstResult
= firstResult
;
35 this.maxResults
= maxResults
;
39 /// Initializes a new instance of the <see cref="QueryRange"/> class.
41 /// <param name="maxResults">The max results.</param>
42 public QueryRange(int maxResults
)
48 /// Gets the first result.
50 /// <value>The first result.</value>
51 public int FirstResult
53 get { return firstResult; }
57 /// Gets the max results.
59 /// <value>The max results.</value>
62 get { return maxResults; }
66 /// Applies this modifier to the query.
68 /// <param name="query">The query</param>
69 public void Apply(IQuery query
)
71 query
.SetFirstResult(FirstResult
);
72 query
.SetMaxResults(MaxResults
);