Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Returning a collection of "Uniques"
 

Pages: 1
LLBLGen Pro Runtime Framework
Returning a collection of "Uniques"
Page:1/1 

  Print all messages in this thread  
Poster Message
Anonymous
User



Location:
Melbourne,Australia
Joined on:
11-Nov-2006 17:40:35
Posted:
0 posts
# Posted on: 28-Oct-2004 18:49:57.  
Heya,

What I need is a way to return a list of only the unique values in a given field, for a given collection.

That may have been vague, so here is an example of what I mean:

I have a collection of sales receipts for a one month period and want to return a list of customers who made a purchase within that period. Customer, obviously, would be a field within the receipts collection, and I can't just return the customer field of each record in my collection, because some customers may have made multiple purchases...

Any ideas? And sorry for dumbing it down so much...

Thanx in advance.
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37632 posts
# Posted on: 28-Oct-2004 21:02:20.  
You want a list with a single field (customerid) or a list of customer objects? The first can be made with a dynamic list (see documentation on typedlists) and a filter, and using the typedlist fetch logic you can specify if you want duplicates or not. When you want objects, you can simply filter on the customer objects, as these will always be unique.

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Anonymous
User



Location:
Melbourne,Australia
Joined on:
11-Nov-2006 17:40:35
Posted:
0 posts
# Posted on: 29-Oct-2004 17:26:00.  
Hmm, thats not quite what I mean, let me try again:

I have a table with the following fields: Date, Customer and TotalBill, where the customer field is a reference into another table called Customers, and the other two fields are just the date of teh transaction and the total amount charged to the customer.

At the end of the month, I want to generate a statement for each customer who has made at least one purchase in the previous 30 days. I want to generate one statement and one statement only, and just have a list of all that customers transacations (if they have had more than one) on it.

So my question is, is there any build in functionality in LLBLGEN to allow me get a list/array of all the customers who have at least one record within the collection retrieved via selectfilters created upon date (ie Table.Date > Now minus 30 days and Table.Date <= Now)?

I hope that was a little more clear. All I really want is an array (or something similar) of all the Customers whose names appear at least once within my retrieved collection...

Thanx again,
Sean
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37632 posts
# Posted on: 29-Oct-2004 19:22:05.  
I illustrate it using SelfServicing.
Code:

CustomerCollection customers = new CustomerCollection();
IRelationCollection relations = new RelationCollection();
relations.Add(CustomerEntity.Relations.SalesReceiptEntityUsingCustomer);
IPredicateExpression filter = new PredicateExpression();
filter.Add(//... add your 2 date compare predicates here)

customers.GetMulti(filter, relations);


So it basicly does an inner join with salesreceipt. This will only keep the customers which have 1 record in that table, and you filter out the rows which have a salesreceipt outside the month range.

Because you fetch objects, these are always unique, so you can then just traverse the collection.


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


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

Version: 2.1.12172008 Final.