How to limit cols returned in GetMulti?

Posts   
 
    
Jared
User
Posts: 8
Joined: 15-Aug-2007
# Posted on: 12-Sep-2007 17:25:01   

This is probably a simple question, but I'm fetching a ton of rows from one of my tables, and for memory reasons, I only want to get the columns I need.

Could anyone point me in the right direction?

Thanks, - Jared

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 12-Sep-2007 18:02:09   

You have the following options:

1- Starting from v.2.5 the concept of execluding fields from the fetch was introduced. (ref: manual "Using the generated code -> SelfServicing/Adapter -> Excluding / Including fields for fetches")

2- You can use the designer to map another entity onto the same table but this time with fewer fields.

3- You can use a TypedList or a DynamicList, to fetch the needed fields. Also you can project the results back to an entityCollection (Projection).

Jared
User
Posts: 8
Joined: 15-Aug-2007
# Posted on: 12-Sep-2007 19:43:22   

Awesome, got it working with a dynamiclist. What's this about projecting it back on to an entity collection?

Jared
User
Posts: 8
Joined: 15-Aug-2007
# Posted on: 12-Sep-2007 20:14:55   

Nevermind, I looked that up myself. I have another quick question though, if anyone knows off hand. Now that I have this DataTable, I'm just doing a for loop through it to get what I need, but it'd be better if I could tell one of the columns to be a primary key and then do table.Rows.Find(). Anyone know if this is possible?

  • Jared
Jared
User
Posts: 8
Joined: 15-Aug-2007
# Posted on: 12-Sep-2007 20:46:41   

Ok, I added a PredicateExpression and now I'm getting some error, which I don't believe has a good reason for happening. On the last line of the following code, I'm getting the error "The multi-part identifier \"dev.dbo.feed_venue.data_load_id\" could not be bound."

Any ideas?


ResultsetFields fields = new ResultsetFields(3);
fields.DefineField(FeedVenueFields.DataSourceItemId, 0, "DataSourceItemId", "FeedVenue");
fields.DefineField(FeedVenueFields.FeedVenueId, 1, "FeedVenueId", "FeedVenue");
fields.DefineField(FeedVenueFields.DataLoadId, 2, "DataLoadId", "FeedVenue");
                
PredicateExpression GetAllForThisDataLoad = new PredicateExpression();
GetAllForThisDataLoad.Add(FeedVenueFields.DataLoadId == dataLoadId);
                
TypedListDAO dao = new TypedListDAO();
dao.GetMultiAsDataTable(fields, dynListAllFeedVenues, 0, null, GetAllForThisDataLoad, null, true, null, null, 0, 0);

JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 12-Sep-2007 21:22:42   

It looks like you may be having problems with _ chars.

Try taking out the table alias definitions as show below.


fields.DefineField(FeedVenueFields.DataSourceItemId, 0, "DataSourceItemId");
fields.DefineField(FeedVenueFields.FeedVenueId, 1, "FeedVenueId");
fields.DefineField(FeedVenueFields.DataLoadId, 2, "DataLoadId");

Jared
User
Posts: 8
Joined: 15-Aug-2007
# Posted on: 12-Sep-2007 22:06:27   

Nice, that worked! Thanks!

  • Jared