Here's a query I did recently for a similar problem:
public IEnumerable<Allocation> FetchAllocationsFor(Resource resource,
DateRange range)
{
const string hql_allocations =
@"SELECT a FROM Resource r JOIN r.Allocations a " +
"WHERE a.Resource = :resource " +
"AND a.TimeRange.StartTime between :start and :end";
return
_sessionFactory.GetCurrentSession().CreateQuery(hql_allocations)
.SetParameter("resource", resource)
.SetDateTime("start", range.Start)
.SetDateTime("end", range.End)
.Future<Allocation>();
}
The DateRange param has nothing to do with NHib, but is useful in my
domain. It does mean you'd have to calculate the 30 day later end
point outside of your query though. If I remember correctly the NHib
between range is inclusive of the end points.
HTH,
Berryl
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.