|
From: <ric...@us...> - 2010-11-10 06:54:19
|
Revision: 5264
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5264&view=rev
Author: ricbrown
Date: 2010-11-10 06:54:12 +0000 (Wed, 10 Nov 2010)
Log Message:
-----------
QueryOver - pushed Skip/Take up to base class so that paging can be applied to IQueryOver<T> as well as IQueryOver<T,U>
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs
trunk/nhibernate/src/NHibernate/IQueryOver.cs
Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2010-11-07 16:26:04 UTC (rev 5263)
+++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2010-11-10 06:54:12 UTC (rev 5264)
@@ -116,12 +116,12 @@
/// <returns></returns>
public QueryOver<TRoot,TRoot> ToRowCountQuery()
{
- return
+ return (QueryOver<TRoot,TRoot>)
Clone()
+ .Select(Projections.RowCount())
.ClearOrders()
.Skip(0)
- .Take(RowSelection.NoValue)
- .Select(Projections.RowCount());
+ .Take(RowSelection.NoValue);
}
/// <summary>
@@ -130,12 +130,12 @@
/// <returns></returns>
public QueryOver<TRoot,TRoot> ToRowCountInt64Query()
{
- return
+ return (QueryOver<TRoot,TRoot>)
Clone()
+ .Select(Projections.RowCountInt64())
.ClearOrders()
.Skip(0)
- .Take(RowSelection.NoValue)
- .Select(Projections.RowCountInt64());
+ .Take(RowSelection.NoValue);
}
/// <summary>
@@ -146,6 +146,42 @@
return new QueryOver<TRoot,TRoot>((CriteriaImpl)criteria.Clone());
}
+ public QueryOver<TRoot> ClearOrders()
+ {
+ criteria.ClearOrders();
+ return this;
+ }
+
+ public QueryOver<TRoot> Skip(int firstResult)
+ {
+ criteria.SetFirstResult(firstResult);
+ return this;
+ }
+
+ public QueryOver<TRoot> Take(int maxResults)
+ {
+ criteria.SetMaxResults(maxResults);
+ return this;
+ }
+
+ public QueryOver<TRoot> Cacheable()
+ {
+ criteria.SetCacheable(true);
+ return this;
+ }
+
+ public QueryOver<TRoot> CacheMode(CacheMode cacheMode)
+ {
+ criteria.SetCacheMode(cacheMode);
+ return this;
+ }
+
+ public QueryOver<TRoot> CacheRegion(string cacheRegion)
+ {
+ criteria.SetCacheRegion(cacheRegion);
+ return this;
+ }
+
/// <summary>
/// Method to allow comparison of detached query in Lambda expression
/// e.g., p => p.Name == myQuery.As<string>
@@ -197,6 +233,24 @@
IQueryOver<TRoot,TRoot> IQueryOver<TRoot>.Clone()
{ return Clone(); }
+ IQueryOver<TRoot> IQueryOver<TRoot>.ClearOrders()
+ { return ClearOrders(); }
+
+ IQueryOver<TRoot> IQueryOver<TRoot>.Skip(int firstResult)
+ { return Skip(firstResult); }
+
+ IQueryOver<TRoot> IQueryOver<TRoot>.Take(int maxResults)
+ { return Take(maxResults); }
+
+ IQueryOver<TRoot> IQueryOver<TRoot>.Cacheable()
+ { return Cacheable(); }
+
+ IQueryOver<TRoot> IQueryOver<TRoot>.CacheMode(CacheMode cacheMode)
+ { return CacheMode(cacheMode); }
+
+ IQueryOver<TRoot> IQueryOver<TRoot>.CacheRegion(string cacheRegion)
+ { return CacheRegion(cacheRegion); }
+
}
/// <summary>
@@ -364,48 +418,12 @@
return new QueryOverOrderBuilder<TRoot,TSubType>(this, path, true);
}
- public QueryOver<TRoot,TSubType> ClearOrders()
- {
- criteria.ClearOrders();
- return this;
- }
-
public QueryOver<TRoot,TSubType> TransformUsing(IResultTransformer resultTransformer)
{
criteria.SetResultTransformer(resultTransformer);
return this;
}
- public QueryOver<TRoot,TSubType> Skip(int firstResult)
- {
- criteria.SetFirstResult(firstResult);
- return this;
- }
-
- public QueryOver<TRoot,TSubType> Take(int maxResults)
- {
- criteria.SetMaxResults(maxResults);
- return this;
- }
-
- public QueryOver<TRoot,TSubType> Cacheable()
- {
- criteria.SetCacheable(true);
- return this;
- }
-
- public QueryOver<TRoot,TSubType> CacheMode(CacheMode cacheMode)
- {
- criteria.SetCacheMode(cacheMode);
- return this;
- }
-
- public QueryOver<TRoot,TSubType> CacheRegion(string cacheRegion)
- {
- criteria.SetCacheRegion(cacheRegion);
- return this;
- }
-
public QueryOverSubqueryBuilder<TRoot,TSubType> WithSubquery
{
get { return new QueryOverSubqueryBuilder<TRoot,TSubType>(this); }
@@ -718,27 +736,9 @@
IQueryOverOrderBuilder<TRoot,TSubType> IQueryOver<TRoot,TSubType>.ThenByAlias(Expression<Func<object>> path)
{ return new IQueryOverOrderBuilder<TRoot,TSubType>(this, path, true); }
- IQueryOver<TRoot,TSubType> IQueryOver<TRoot, TSubType>.ClearOrders()
- { return ClearOrders(); }
-
IQueryOver<TRoot,TSubType> IQueryOver<TRoot,TSubType>.TransformUsing(IResultTransformer resultTransformer)
{ return TransformUsing(resultTransformer); }
- IQueryOver<TRoot,TSubType> IQueryOver<TRoot,TSubType>.Skip(int firstResult)
- { return Skip(firstResult); }
-
- IQueryOver<TRoot,TSubType> IQueryOver<TRoot,TSubType>.Take(int maxResults)
- { return Take(maxResults); }
-
- IQueryOver<TRoot,TSubType> IQueryOver<TRoot,TSubType>.Cacheable()
- { return Cacheable(); }
-
- IQueryOver<TRoot,TSubType> IQueryOver<TRoot,TSubType>.CacheMode(CacheMode cacheMode)
- { return CacheMode(cacheMode); }
-
- IQueryOver<TRoot,TSubType> IQueryOver<TRoot,TSubType>.CacheRegion(string cacheRegion)
- { return CacheRegion(cacheRegion); }
-
IQueryOverSubqueryBuilder<TRoot,TSubType> IQueryOver<TRoot,TSubType>.WithSubquery
{ get { return new IQueryOverSubqueryBuilder<TRoot,TSubType>(this); } }
Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2010-11-07 16:26:04 UTC (rev 5263)
+++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2010-11-10 06:54:12 UTC (rev 5264)
@@ -120,6 +120,40 @@
/// </summary>
IQueryOver<TRoot,TRoot> Clone();
+ /// <summary>
+ /// Clear all orders from the query.
+ /// </summary>
+ IQueryOver<TRoot> ClearOrders();
+
+ /// <summary>
+ /// Set the first result to be retrieved
+ /// </summary>
+ /// <param name="firstResult"></param>
+ IQueryOver<TRoot> Skip(int firstResult);
+
+ /// <summary>
+ /// Set a limit upon the number of objects to be retrieved
+ /// </summary>
+ /// <param name="maxResults"></param>
+ IQueryOver<TRoot> Take(int maxResults);
+
+ /// <summary>
+ /// Enable caching of this query result set
+ /// </summary>
+ IQueryOver<TRoot> Cacheable();
+
+ /// <summary> Override the cache mode for this particular query. </summary>
+ /// <param name="cacheMode">The cache mode to use. </param>
+ /// <returns> this (for method chaining) </returns>
+ IQueryOver<TRoot> CacheMode(CacheMode cacheMode);
+
+ /// <summary>
+ /// Set the name of the cache region.
+ /// </summary>
+ /// <param name="cacheRegion">the name of a query cache region, or <see langword="null" />
+ /// for the default query cache</param>
+ IQueryOver<TRoot> CacheRegion(string cacheRegion);
+
}
/// <summary>
@@ -301,45 +335,11 @@
IQueryOverOrderBuilder<TRoot,TSubType> ThenByAlias(Expression<Func<object>> path);
/// <summary>
- /// Clear all orders from the query.
- /// </summary>
- IQueryOver<TRoot, TSubType> ClearOrders();
-
- /// <summary>
/// Transform the results using the supplied IResultTransformer
/// </summary>
IQueryOver<TRoot,TSubType> TransformUsing(IResultTransformer resultTransformer);
/// <summary>
- /// Set the first result to be retrieved
- /// </summary>
- /// <param name="firstResult"></param>
- IQueryOver<TRoot,TSubType> Skip(int firstResult);
-
- /// <summary>
- /// Set a limit upon the number of objects to be retrieved
- /// </summary>
- /// <param name="maxResults"></param>
- IQueryOver<TRoot,TSubType> Take(int maxResults);
-
- /// <summary>
- /// Enable caching of this query result set
- /// </summary>
- IQueryOver<TRoot,TSubType> Cacheable();
-
- /// <summary> Override the cache mode for this particular query. </summary>
- /// <param name="cacheMode">The cache mode to use. </param>
- /// <returns> this (for method chaining) </returns>
- IQueryOver<TRoot,TSubType> CacheMode(CacheMode cacheMode);
-
- /// <summary>
- /// Set the name of the cache region.
- /// </summary>
- /// <param name="cacheRegion">the name of a query cache region, or <see langword="null" />
- /// for the default query cache</param>
- IQueryOver<TRoot,TSubType> CacheRegion(string cacheRegion);
-
- /// <summary>
/// Add a subquery expression
/// </summary>
IQueryOverSubqueryBuilder<TRoot,TSubType> WithSubquery { get; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|