|
From: <Ric...@us...> - 2009-06-24 19:22:42
|
Revision: 4525
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4525&view=rev
Author: RicBrown
Date: 2009-06-24 19:22:41 +0000 (Wed, 24 Jun 2009)
Log Message:
-----------
Added integration test and implementation of Criteria<T> through to the DB.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs
trunk/nhibernate/src/NHibernate/ISession.cs
trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs
trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs
trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs
Modified: trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-24 18:58:43 UTC (rev 4524)
+++ trunk/nhibernate/src/NHibernate/ICriteriaOfT.cs 2009-06-24 19:22:41 UTC (rev 4525)
@@ -1,5 +1,6 @@
using System;
+using System.Collections.Generic;
using System.Linq.Expressions;
namespace NHibernate
@@ -27,6 +28,12 @@
/// <returns>criteria instance</returns>
ICriteria<T> Add(Expression<Func<T, bool>> expression);
+ /// <summary>
+ /// Get the results of the root type and fill the <see cref="IList<T>"/>
+ /// </summary>
+ /// <param name="results">The list filled with the results.</param>
+ IList<T> List();
+
}
}
Modified: trunk/nhibernate/src/NHibernate/ISession.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/ISession.cs 2009-06-24 18:58:43 UTC (rev 4524)
+++ trunk/nhibernate/src/NHibernate/ISession.cs 2009-06-24 19:22:41 UTC (rev 4525)
@@ -783,6 +783,13 @@
ICriteria CreateCriteria(string entityName, string alias);
/// <summary>
+ /// Creates a new <c>ICriteria<T></c> for the entity class.
+ /// </summary>
+ /// <typeparam name="T">The entity class</typeparam>
+ /// <returns>An ICriteria<T> object</returns>
+ ICriteria<T> QueryOver<T>() where T : class;
+
+ /// <summary>
/// Create a new instance of <c>Query</c> for the given query string
/// </summary>
/// <param name="queryString">A hibernate query string</param>
Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-24 18:58:43 UTC (rev 4524)
+++ trunk/nhibernate/src/NHibernate/Impl/CriteriaOfTImpl.cs 2009-06-24 19:22:41 UTC (rev 4525)
@@ -1,5 +1,6 @@
using System;
+using System.Collections.Generic;
using System.Linq.Expressions;
namespace NHibernate.Impl
@@ -30,6 +31,11 @@
return this;
}
+ IList<T> ICriteria<T>.List()
+ {
+ return _criteria.List<T>();
+ }
+
}
}
Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-06-24 18:58:43 UTC (rev 4524)
+++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-06-24 19:22:41 UTC (rev 4525)
@@ -1871,6 +1871,14 @@
}
}
+ public ICriteria<T> QueryOver<T>() where T : class
+ {
+ using (new SessionIdLoggingContext(SessionId))
+ {
+ return new CriteriaImpl<T>(CreateCriteria(typeof(T)));
+ }
+ }
+
public override IList List(CriteriaImpl criteria)
{
using (new SessionIdLoggingContext(SessionId))
Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-24 18:58:43 UTC (rev 4524)
+++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-24 19:22:41 UTC (rev 4525)
@@ -66,6 +66,30 @@
}
}
+ [Test]
+ public void ICriteriaOfT_SimpleCriterion()
+ {
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Save(new Person() { Name = "test person 1" });
+ s.Save(new Person() { Name = "test person 2" });
+ s.Save(new Person() { Name = "test person 3" });
+
+ t.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ {
+ IList<Person> actual =
+ s.QueryOver<Person>()
+ .Add(p => p.Name == "test person 2")
+ .List();
+
+ Assert.That(actual.Count, Is.EqualTo(1));
+ }
+ }
+
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|