use a projection instead. it will be much more efficient.

On Nov 7, 10:25 pm, Rob Walker <[email protected]> wrote:
> I have 4 tables: organization, donor, event, gift with a
> relationships: donor has an organization, event has an organization,
> gift has an event and donor.
>
> I want to select all donors that have donated gifts to a specific
> event ordered by their total donations.
>
> Currently I can select all the active donors for an event:
>
>             var active_donors =
>                     DetachedCriteria.For<Az.Item>()
>                         .Add(Restrictions.Eq("Event", current_event))
>                         .SetProjection(Projections.GroupProperty("Donor"));
>
>            IList<Donor> donors =
> Session.CreateCriteria(typeof(Az.Donor))
>                     .Add(Restrictions.Eq("Organization",
> current_organization))
>                     .Add(Subqueries.PropertyIn("Id", active_donors))
>                     .List<Az.Donor>();
>
> But I can't work out how to include the the total donations for the
> donor, or how to order by it.
>
> Any suggestions?
>
> Thanks.

-- 
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.

Reply via email to