|
From: <Ric...@us...> - 2009-06-27 07:07:51
|
Revision: 4536
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4536&view=rev
Author: RicBrown
Date: 2009-06-27 07:07:50 +0000 (Sat, 27 Jun 2009)
Log Message:
-----------
Added overload for And() with same semantics as Where().
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs
trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs
trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs
Modified: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-27 06:53:39 UTC (rev 4535)
+++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-27 07:07:50 UTC (rev 4536)
@@ -29,6 +29,13 @@
ICriteria<T> And(Expression<Func<T, bool>> expression);
/// <summary>
+ /// Add criterion expressed as a lambda expression
+ /// </summary>
+ /// <param name="expression">Lambda expression</param>
+ /// <returns>criteria instance</returns>
+ ICriteria<T> And(Expression<Func<bool>> expression);
+
+ /// <summary>
/// Identical semantics to Add() to allow more readable queries
/// </summary>
/// <param name="expression">Lambda expression</param>
@@ -36,7 +43,7 @@
ICriteria<T> Where(Expression<Func<T, bool>> expression);
/// <summary>
- /// Add criterion expressed as a lambda expression
+ /// Identical semantics to Add() to allow more readable queries
/// </summary>
/// <param name="expression">Lambda expression</param>
/// <returns>criteria instance</returns>
Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-27 06:53:39 UTC (rev 4535)
+++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-27 07:07:50 UTC (rev 4536)
@@ -27,20 +27,22 @@
ICriteria<T> ICriteria<T>.And(Expression<Func<T, bool>> expression)
{
- _criteria.Add(expression);
- return this;
+ return Add(expression);
}
+ ICriteria<T> ICriteria<T>.And(Expression<Func<bool>> expression)
+ {
+ return Add(expression);
+ }
+
ICriteria<T> ICriteria<T>.Where(Expression<Func<T, bool>> expression)
{
- _criteria.Add(expression);
- return this;
+ return Add(expression);
}
ICriteria<T> ICriteria<T>.Where(Expression<Func<bool>> expression)
{
- _criteria.Add(ExpressionProcessor.ProcessExpression(expression));
- return this;
+ return Add(expression);
}
IList<T> ICriteria<T>.List()
@@ -48,6 +50,18 @@
return _criteria.List<T>();
}
+ private CriteriaImpl<T> Add(Expression<Func<T, bool>> expression)
+ {
+ _criteria.Add(ExpressionProcessor.ProcessExpression<T>(expression));
+ return this;
+ }
+
+ private CriteriaImpl<T> Add(Expression<Func<bool>> expression)
+ {
+ _criteria.Add(ExpressionProcessor.ProcessExpression(expression));
+ return this;
+ }
+
}
}
Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-27 06:53:39 UTC (rev 4535)
+++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaOfTFixture.cs 2009-06-27 07:07:50 UTC (rev 4536)
@@ -32,12 +32,15 @@
[Test]
public void Where_BehavesTheSameAs_And()
{
+ Person personAlias = null;
Impl.CriteriaImpl<Person> expected = (Impl.CriteriaImpl<Person>)
- CreateTestQueryOver<Person>()
+ CreateTestQueryOver<Person>(() => personAlias)
+ .And(() => personAlias.Name == "test name")
.And(p => p.Name == "test name");
ICriteria<Person> actual =
- CreateTestQueryOver<Person>()
+ CreateTestQueryOver<Person>(() => personAlias)
+ .Where(() => personAlias.Name == "test name")
.Where(p => p.Name == "test name");
AssertCriteriaAreEqual(expected.UnderlyingCriteria, actual);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|