I understand that you can use filters in NHibernate to only load parts of child collections. I would like to be able to do this using the Criteria API, instead of HQL. Is this possible?
Some specifics from my application: I'm trying to load the invoices for a given vendor that occur after a given date, and have positive line items.
The entities look something like this:
public partial class Vendor
{
public virtual string Name {get; set;}
//A bunch of other properties
public virtual ICollection<Invoice> Invoices {get; protected set;}
}
public partial class Invoice
{
public virtual DateTime? Date {get; set;}
public virtual ICollection<LineItem> LineItems {get; protected set;}
}
public partial class LineItem
{
public virtual decimal Amount {get; set;}
}
Originally, I was just pulling line items, but now they want the user to be able to input a bunch of criteria to select the vendor. I already have the UI/code to allow the user to specify vendors using the Criteria API, so I'd like to apply a filter to only pull the LineItems that are positive for Invoices that occur after a given date. Is this possible using the Criteria API? If not, can I at least get away without adding the filter-defs to my mapping file?