Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add FindMostRecent() method

svn path=/trunk/moma-tool/; revision=111703
  • Loading branch information...
commit 6ab607eb4d10f39e45973906f2dc2f6008cdd489 1 parent 12f518f
@dickp dickp authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 MomaTool.Database/Report.cs
View
19 MomaTool.Database/Report.cs
@@ -1,5 +1,7 @@
using System;
+using System.Collections;
using Castle.ActiveRecord;
+using NHibernate;
using NHibernate.Expression;
namespace MomaTool.Database
@@ -184,6 +186,23 @@ public static Report FindByReportFilename (string file)
{
return(FindOne (Expression.Eq ("ReportFilename", file)));
}
+
+ public static Report[] FindMostRecent(int count)
+ {
+ return(Report[])Execute(
+ delegate(ISession session, object instance) {
+ IQuery query = session.CreateQuery("from Report r order by create_date desc");
+
+ query.SetMaxResults(count);
+
+ IList results = query.List();
+
+ Report[] reports = new Report[results.Count];
+ results.CopyTo(reports, 0);
+
+ return reports;
+ }, null);
+ }
public static Report CreateOrUpdate (string file,
MomaDefinition def,
Please sign in to comment.
Something went wrong with that request. Please try again.