Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Getting x orders, each placed by another customer
 

Pages: 1
LLBLGen Pro Runtime Framework
Getting x orders, each placed by another customer
Page:1/1 

  Print all messages in this thread  
Poster Message
Pablo
User



Location:
Sneek
Joined on:
21-Mar-2005 01:17:52
Posted:
81 posts
# Posted on: 25-Nov-2009 14:54:31.  
Hello,
Could anyone be so kind to have a look at the following ...?

I have an Order and Customer table. Each Order is placed by a Customer. Customer can place more than 0 Orders. Order has CreateDateTime.

I want to get a set of 'most recent created' orders, but each order should have a unique customer.

So say ...
order 8, 16h00, customer 1
order 7, 15h00, customer 2
order 6, 14h00, customer 2
order 5, 15h45, customer 3
order 4, 15h40, customer 3
order 3, 15h35, customer 3
order 2, 15h30, customer 4
order 1, 15h25, customer 4

I would like to get an ordercollection with the orders no: 8, 7, 5 and 2

Thanx for any suggestion,
Paul





  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14473 posts
# Posted on: 25-Nov-2009 16:48:59.  
So you want to get the latest order for each customer.

This can be done by Fetching the Customers, and supply a prefetchPath to orders.
You should pass a sortExpression the prefecthPath to sort on the CreateDateTime Descendingly, and specify 1 as the maximumNumberOfItems for the prefetchPath (Top 1).

This will fetch all Customers, and the latest Order for each Customer.


  Top
Pablo
User



Location:
Sneek
Joined on:
21-Mar-2005 01:17:52
Posted:
81 posts
# Posted on: 25-Nov-2009 16:58:54.  
Hi Walaa,
Your first line is correct!
Your suggestion ... perfect!
Many thanx!!!
Paul
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.