Skip to content

Commit

Permalink
Fixed NH-1104 creating a new projection
Browse files Browse the repository at this point in the history
SVN: trunk@3411
  • Loading branch information
fabiomaulo committed Mar 21, 2008
1 parent d275e81 commit bcb7f1a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/NHibernate.Test/Criteria/CriteriaQueryTest.cs
Expand Up @@ -668,6 +668,14 @@ public void ProjectionsTest()

Assert.AreEqual(7, array.Length);

ProjectionList pp1 = Projections.ProjectionList().Add(Projections.RowCountInt64());


object r = s.CreateCriteria(typeof(Enrolment))
.SetProjection(pp1)
.UniqueResult();
Assert.AreEqual(typeof (Int64), r.GetType());

IList list = s.CreateCriteria(typeof(Enrolment))
.CreateAlias("Student", "st")
.CreateAlias("Course", "co")
Expand Down
11 changes: 10 additions & 1 deletion src/NHibernate/Criterion/Projections.cs
Expand Up @@ -42,12 +42,21 @@ public static ProjectionList ProjectionList()
/// <summary>
/// The query row count, ie. <tt>count(*)</tt>
/// </summary>
/// <returns></returns>
/// <returns>The RowCount projection mapped to an <see cref="Int32"/>.</returns>
public static IProjection RowCount()
{
return new RowCountProjection();
}

/// <summary>
/// The query row count, ie. <tt>count(*)</tt>
/// </summary>
/// <returns>The RowCount projection mapped to an <see cref="Int64"/>.</returns>
public static IProjection RowCountInt64()
{
return new RowCountInt64Projection();
}

/// <summary>
/// A property value count
/// </summary>
Expand Down
14 changes: 14 additions & 0 deletions src/NHibernate/Criterion/RowCountInt64Projection.cs
@@ -0,0 +1,14 @@
using System;
using NHibernate.Type;

namespace NHibernate.Criterion
{
[Serializable]
public class RowCountInt64Projection : RowCountProjection
{
public override IType[] GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery)
{
return new IType[] { NHibernateUtil.Int64 };
}
}
}
1 change: 1 addition & 0 deletions src/NHibernate/NHibernate-2.0.csproj
Expand Up @@ -556,6 +556,7 @@
<Compile Include="Context\WebSessionContext.cs" />
<Compile Include="CriteriaTransformer.cs" />
<Compile Include="Criterion\Restrictions.cs" />
<Compile Include="Criterion\RowCountInt64Projection.cs" />
<Compile Include="DebugHelpers\DictionaryProxy.cs" />
<Compile Include="DebugHelpers\CollectionProxy.cs" />
<Compile Include="Dialect\Function\AnsiExtractFunction.cs" />
Expand Down

0 comments on commit bcb7f1a

Please sign in to comment.