Can I specify what fields to return?

Posts   
 
    
Posts: 497
Joined: 08-Apr-2004
# Posted on: 19-Jul-2004 14:31:26   

Hi.

Does anyone know if its possible for me in my code to specify what fields are returned? I'm sure I saw something like this recently, but can't seem to remember where....

I'm using adaptor model, and I think I need to "fetch as typed list" or something to get it to only get certain columns.... anyone?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 19-Jul-2004 15:01:50   

in a datatable? If yes, use the FetchTypedList method indeed. You can specify a ResultsetFields instance for the fields list to return. See a generated typed list for details (BuildResultset())

Frans Bouma | Lead developer LLBLGen Pro
Posts: 497
Joined: 08-Apr-2004
# Posted on: 30-Jul-2004 12:37:58   

Thanks Frans,

So the ResultSetField allows me to specify fields from more than one table, is that correct? For example, I need to get all my "customer" fields, plus their "Priority Name" only from a Priority lookup table, assuming in this example that "Customer" has an "Priority_ID" that maps to the priority table?

At the moment, I am creating typed lists to achieve this kind of thing (its the fastest in terms of perf),

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 30-Jul-2004 16:17:03   

MattWoberts wrote:

Thanks Frans,

So the ResultSetField allows me to specify fields from more than one table, is that correct?

Yes, it's the building block for a typed list. simple_smile Please check the generated code for a typed list for its details simple_smile

For example, I need to get all my "customer" fields, plus their "Priority Name" only from a Priority lookup table, assuming in this example that "Customer" has an "Priority_ID" that maps to the priority table? At the moment, I am creating typed lists to achieve this kind of thing (its the fastest in terms of perf),

Typed lists are still the way to do this, you can however, in code, create lists using normal datatables as well, using ResultsetFields simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Posts: 497
Joined: 08-Apr-2004
# Posted on: 30-Jul-2004 17:49:44   

Thanks Frans wink

As you might have guessed, I was mulling this over as an alternative to creating typed lists in the designer, simply to remove the need for creating the same typed list on both the Oracle project and the SQL Server project that we have.

By the way I really appreciate your quick response to my postings - its a fantastic help to me simple_smile

Posts: 497
Joined: 08-Apr-2004
# Posted on: 14-Dec-2004 15:10:31   

Hello again Frans!

Please can you tell me if there is an easy way to create a dynamic list, based on all fields from table X, plus just 2 fields from table Y.

At the moment I am simply defining a lot of ResultSetFields....is that right?

Matt

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 14-Dec-2004 17:00:55   

ResultsetFields is a class derived from EntityFields2 so you can simply do:

CustomerEntity c = new CustomerEntity(); OrderEntity o = new OrderEntity(); ResultsetFields fields = new ResultsetFields(c.Fields.Count + 2); for(int i=0;i<c.Fields.Count) { fields[i]=c.Fields[i]; } fields[c.Fields.Count] = o.Fields["OrderDate"]; fields[c.Fields.Count+1] = o.Fields["ShippingDate"];

If I'm not mistaken, that should do it. You of course want to set aliasses here and there, just do that on teh fields you want the aliasses on, also for aggregates and expressions.

Frans Bouma | Lead developer LLBLGen Pro