|
From: <Ric...@us...> - 2009-06-29 19:46:12
|
Revision: 4545
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4545&view=rev
Author: RicBrown
Date: 2009-06-29 19:46:11 +0000 (Mon, 29 Jun 2009)
Log Message:
-----------
Added integration test for DetachedCriteria<T>.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs
trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs 2009-06-29 19:38:33 UTC (rev 4544)
+++ trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteriaOfT.cs 2009-06-29 19:46:11 UTC (rev 4545)
@@ -27,6 +27,14 @@
_criteria = detachedCriteria;
}
+ /// <summary>
+ /// Get an executable instance of <c>Criteria<T></c>,
+ /// to actually run the query.</summary>
+ public ICriteria<T> GetExecutableCriteria(ISession session)
+ {
+ return new CriteriaImpl<T>(_criteria.GetExecutableCriteria(session));
+ }
+
public DetachedCriteria<T> And(Expression<Func<T, bool>> expression)
{
return Add(expression);
Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-29 19:38:33 UTC (rev 4544)
+++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-29 19:46:11 UTC (rev 4545)
@@ -67,6 +67,30 @@
}
}
+ [Test]
+ public void DetachedCriteriaOfT_SimpleCriterion()
+ {
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Save(new Person() { Name = "test person 1", Age = 20 });
+ t.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ {
+ var personQuery =
+ DetachedCriteria.QueryOver<Person>()
+ .Where(p => p.Name == "test person 1");
+
+ IList<Person> actual =
+ personQuery.GetExecutableCriteria(s)
+ .List();
+
+ Assert.That(actual[0].Age, Is.EqualTo(20));
+ }
+ }
+
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|