Accessing Properties as datatables

Posts   
 
    
jbliss1234
User
Posts: 42
Joined: 04-May-2007
# Posted on: 10-May-2007 22:03:06   

Let us say my Customer class has an Orders collection. What I would like to do (in some situations) is to access the Orders collection as a Datatable, without doing much further coding. (And also without first hydrating the entire orders collection from the database and then creating the datatable. The goal is to query the database for only those fields of the Order table that I am interested in). Is this possible?

It seems like the Orders.GetMultiAsDatatable() method wants a bunch of parameters, and all I want to do is to return a datatable containing this customers orders without having to reconstruct the query. So in pseudocode

dim cust as CustomerEntity = new CustomerEntity(100)

//Now instead of

cust .Orders

//I want:

cust.GetOrdersAsDatatable(New IEntityField() {OrderFields.OrderId, OrderFields.Date})

in order to get an orders datatable containing only 2 fields that I want.

We are looking for something like this in order to solve a specific performance problem, which we believe is being caused by fetching collections of objects that have too many fields, where we really want only 2 or 3 columns.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 11-May-2007 08:42:43   

Just use a dynamicList, and pass a filter like: (OrderFields.CustomerID == xx) That's what they were made for, and a DynamicList is actually a DataTable.

Please refer to the LLBLGen Pro manual: "Using the generated code -> SelfServicing -> Using TypedViews, TypedLists and Dynamic Lists -> Using Dynamic Lists"