The reason I can't do that is I'm actually using the AliasToBean transformer to create a dto.
Foo = BusinessTransaction Bar = Status I select a bunch of information about my business transaction. One of those things I need is the most recent status. I could do a separate query which is the direction I'm heading soon but I'm wording if something in http://ayende.com/Blog/archive/2007/08/30/Slicing-amp-Dicing-Queries-with-NHibernate.aspx could provide the answer I need. I'm trying to understand it but having a "fun" time so far :) Any tips would be appreciated. The world needs a good ICriteria/HQL book... On Dec 18, 3:40 pm, "Will Shaver" <[email protected]> wrote: > Why can't you just get the most recent 'Bar' and then navigate to the parent > foo in c#? > > session.CreateCriteria(typeof(Bar), "bar") > .AddOrder(Order.Desc("bars.Added_On")) > .SetMaxResult(1) > > If you need to restrict this to a certain ParentFood > > .Add(Restrictions.Eq("bar.ParentFood", foo)) > > Then you'll get a 'bar' as a result. > > Bar b = criteria.List<Bar>()[0]; > > Foo f = b.Foo; > > ... > > And from now on don't ask using Foo and Bar. Please use something else! > > -Will > > On Thu, Dec 18, 2008 at 2:23 PM, Shane C <[email protected]> wrote: > > > I have a class Foo which has a list of Bar instances. > > > Foo > > Bars : IList<Bar> > > > And the Bar class which has the following > > > ParentFood Foo > > Added_On int > > > I want to select all Foos and return only the most recent Bar > > > Session.CreateCriteria(typeof(Foo), "foo") > > .CreateCriteria("Bars", "bars") > > .AddOrder(Order.Desc("bars.Added_On")) > > .SetMaxResult(1) > > > But the MaxResult works against Foo. Obviously I need to create a > > separate criteria but I'm not sure how I would link it back to the Foo > > criteria to get the ParentFoo. > > > Thoughts? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
