Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Add FindMostRecent() method
Browse files Browse the repository at this point in the history
svn path=/trunk/moma-tool/; revision=111703
  • Loading branch information
dickp committed Aug 27, 2008
1 parent 12f518f commit 6ab607e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions MomaTool.Database/Report.cs
@@ -1,5 +1,7 @@
using System; using System;
using System.Collections;
using Castle.ActiveRecord; using Castle.ActiveRecord;
using NHibernate;
using NHibernate.Expression; using NHibernate.Expression;


namespace MomaTool.Database namespace MomaTool.Database
Expand Down Expand Up @@ -184,6 +186,23 @@ public static Report FindByReportFilename (string file)
{ {
return(FindOne (Expression.Eq ("ReportFilename", 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, public static Report CreateOrUpdate (string file,
MomaDefinition def, MomaDefinition def,
Expand Down

0 comments on commit 6ab607e

Please sign in to comment.