|
From: <ric...@us...> - 2009-07-27 22:29:02
|
Revision: 4665
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4665&view=rev
Author: ricbrown
Date: 2009-07-27 22:28:49 +0000 (Mon, 27 Jul 2009)
Log Message:
-----------
Added paging methods to IQueryOver.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs
trunk/nhibernate/src/NHibernate/IQueryOver.cs
trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-27 21:24:37 UTC (rev 4664)
+++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-07-27 22:28:49 UTC (rev 4665)
@@ -93,6 +93,18 @@
return AddOrder(path, orderDelegate);
}
+ public IQueryOver<T> Skip(int firstResult)
+ {
+ _criteria.SetFirstResult(firstResult);
+ return this;
+ }
+
+ public IQueryOver<T> Take(int maxResults)
+ {
+ _criteria.SetMaxResults(maxResults);
+ return this;
+ }
+
public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path)
{
return new QueryOver<U>(_impl,
@@ -243,6 +255,9 @@
}
+ ICriteria IQueryOver<T>.UnderlyingCriteria
+ { get { return UnderlyingCriteria; } }
+
IQueryOver<T> IQueryOver<T>.And(Expression<Func<T, bool>> expression)
{ return And(expression); }
@@ -270,6 +285,12 @@
IQueryOver<T> IQueryOver<T>.ThenBy(Expression<Func<object>> path, Func<string, Order> orderDelegate)
{ return ThenBy(path, orderDelegate); }
+ IQueryOver<T> IQueryOver<T>.Skip(int firstResult)
+ { return Skip(firstResult); }
+
+ IQueryOver<T> IQueryOver<T>.Take(int maxResults)
+ { return Take(maxResults); }
+
IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, U>> path)
{ return JoinQueryOver(path); }
Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-27 21:24:37 UTC (rev 4664)
+++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-07-27 22:28:49 UTC (rev 4665)
@@ -97,6 +97,18 @@
IQueryOver<T> ThenBy(Expression<Func<object>> path, Func<string, Order> orderDelegate);
/// <summary>
+ /// Set the first result to be retrieved
+ /// </summary>
+ /// <param name="firstResult"></param>
+ IQueryOver<T> Skip(int firstResult);
+
+ /// <summary>
+ /// Set a limit upon the number of objects to be retrieved
+ /// </summary>
+ /// <param name="maxResults"></param>
+ IQueryOver<T> Take(int maxResults);
+
+ /// <summary>
/// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity
/// </summary>
/// <typeparam name="U">Type of sub-criteria</typeparam>
Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-27 21:24:37 UTC (rev 4664)
+++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-07-27 22:28:49 UTC (rev 4665)
@@ -281,6 +281,22 @@
AssertCriteriaAreEqual(expected, actual);
}
+ [Test]
+ public void Paging()
+ {
+ ICriteria expected =
+ CreateTestCriteria(typeof(Person))
+ .SetFirstResult(90)
+ .SetMaxResults(10);
+
+ IQueryOver<Person> actual =
+ CreateTestQueryOver<Person>()
+ .Skip(90)
+ .Take(10);
+
+ AssertCriteriaAreEqual(expected, actual);
+ }
+
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|