FIlter Large Collections
Hello,
I've setup a couple classes (Client, Invoice) that have a one-to-many relationship between them. I can write the following:
Client client = GetClient();
foreach (Invoice invoice in client.Invoices)
{
// Check if the invoice has been paid, if not then do stuff to get it paid.
}
But what I really want to do is have the line:
client.Invoices
only return the unpaid invoices. If I could write something like on of the below:
client.Invoices.Filter("Some Filter")
client.UnpaidInvoices()
I know I could write a customer query using CreateCriteria or use the Session.CreateFilter but I was wondering if there was an better way.
Thank you.
Support Staff 2 Posted by James Gregory on 16 May, 2010 05:24 PM
Your best bet is to use the criteria for queries such as this, that's what it's designed for.
James Gregory closed this discussion on 16 May, 2010 05:24 PM.
Paul Batum re-opened this discussion on 17 May, 2010 05:01 AM
Support Staff 3 Posted by Paul Batum on 17 May, 2010 05:01 AM
You could also use 'where' to filter the invoices. You provide a SQL predicate to be included in the where statement. Something like:
I forget the syntax exactly but you should be able to find some examples on google.