Hi,

In my domain model I have:

PayrollBatch > (has many) PayrollBatchItem > (has one) Driver.

So let's say I want to "get all payroll batches for driver x"

I am doing this using DetachedCriteria:

            var batchItems = DetachedCriteria.For<PayrollBatchItem>()
                .Add(Restrictions.Eq("Driver.Id", _driver.Id))
                .SetProjection(Projections.Property("PayrollBatch.Id"));

            var query = session.CreateCriteria<PayrollBatch>()
                .Add(Subqueries.Exists(batchItems))
                .List<PayrollBatch>();

This works great and any batches that contain payroll batch items
associated with the driver are returned.

My question:

PayrollBatch has a property "Total" that calculates the total value of
it's PayrollBatchItems.

How can I change my criteria so that I return all payroll batches for
driver x, with each batch only containing the driver's payroll items.

This way when I show a list of the batches and their totals, they will
display the total for the DRIVER's items.

Thanks,
Ben

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