0

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?

Neil
  • 858
  • 1
  • 8
  • 13

1 Answers1

0

Updated the answer, didn't read it well the first time... I don't know if this will help but I ran into the same issue where I only wanted actives being pulled of a child collection. This uses queryover but it's a wrapper on top of criteria so it can be done... Here it is...

Community
  • 1
  • 1
gt124
  • 1,238
  • 13
  • 23
  • Thanks, but this is not what I'm looking for. This would find a list of vendors, but what I want is to only pull the invoice details that match a given criteria. – Neil May 04 '11 at 19:26