|
From: <ric...@us...> - 2009-10-01 10:02:47
|
Revision: 4735
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4735&view=rev
Author: ricbrown
Date: 2009-10-01 10:02:34 +0000 (Thu, 01 Oct 2009)
Log Message:
-----------
Added arbitrary IProjection to IQueryOver (allows protected properties, and eventual lambda-expression overloads for projections).
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-09-30 13:56:12 UTC (rev 4734)
+++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-10-01 10:02:34 UTC (rev 4735)
@@ -83,6 +83,12 @@
return this;
}
+ public QueryOver<T> Select(params IProjection[] projections)
+ {
+ _criteria.SetProjection(projections);
+ return this;
+ }
+
public QueryOverOrderBuilder<T> OrderBy(Expression<Func<T, object>> path)
{
return new QueryOverOrderBuilder<T>(this, path);
@@ -346,6 +352,9 @@
IQueryOver<T> IQueryOver<T>.Select(params Expression<Func<T, object>>[] projections)
{ return Select(projections); }
+ IQueryOver<T> IQueryOver<T>.Select(params IProjection[] projections)
+ { return Select(projections); }
+
IQueryOverOrderBuilder<T> IQueryOver<T>.OrderBy(Expression<Func<T, object>> path)
{ return new IQueryOverOrderBuilder<T>(this, path); }
Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-09-30 13:56:12 UTC (rev 4734)
+++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-10-01 10:02:34 UTC (rev 4735)
@@ -75,6 +75,11 @@
IQueryOver<T> Select(params Expression<Func<T, object>>[] projections);
/// <summary>
+ /// Add arbitrary IProjections to query
+ /// </summary>
+ IQueryOver<T> Select(params IProjection[] projections);
+
+ /// <summary>
/// Add order expressed as a lambda expression
/// </summary>
/// <param name="path">Lambda expression</param>
Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-09-30 13:56:12 UTC (rev 4734)
+++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-10-01 10:02:34 UTC (rev 4735)
@@ -122,11 +122,13 @@
{
ICriteria expected =
CreateTestCriteria(typeof(Person))
+ .SetProjection(Projections.Property("Name"))
.Add(Restrictions.Eq("Name", "test name"))
.Add(Restrictions.Not(Restrictions.Eq("Name", "not test name")));
IQueryOver<Person> actual =
CreateTestQueryOver<Person>()
+ .Select(Projections.Property("Name"))
.Where(Restrictions.Eq("Name", "test name"))
.And(Restrictions.Not(Restrictions.Eq("Name", "not test name")));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|