Typed Lists

Posts   
 
    
hplloyd
User
Posts: 191
Joined: 29-Oct-2004
# Posted on: 07-Jan-2005 15:38:10   

I want to get a typed list of 2 or more related tables... With LLBL this is a very simple process

I set up a Typed List in code thus by creating a ResultSetFields object, adding the field to it, add the relations, add the where clauses and the sort orders and yippee done.

My problem is that this can get long winded especially if I am dealing with lots of tables.

Say I have a single table which has loads of lookup tables with (m:1) relations attached to it.

Is there a quicker and neater way of retrieving a Typed List That contains all the fields not only of the main table but of all the lookup tables as well?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 07-Jan-2005 19:18:32   

If you don't use an entity more than once in the typed list, you can of course use the designer to create the list.

Frans Bouma | Lead developer LLBLGen Pro
Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 08-Jan-2005 07:14:14   

The designer approach is always an option, but I wrote the code below in another post, it could be of some use to you:


// create the group by clause & result set fields
ResultsetFields fields = CustomResultsetFields.AuthorContentList();
IGroupByCollection groupByClause = new GroupByCollection();
for (int i = 0; i < fields.Count ; i++)
{
    IEntityField2 field = fields[i] as IEntityField2;
    if (field.AggregateFunctionToApply == AggregateFunction.None)
    {
        groupByClause.Add(field);
    }
}


What the code really does is loop through an entity and adds the field object to the IGroupByClause.

AuthorContentList is a method that returns a ResultsetFields object. I dont see why you couldnt take a similar approach, as you should be able to add all fields in entity 1,2,3,... n to a ResultsetFields collection.

You could also probably get really crazy and use the microsoft configuration application block to store an array of entities to use for a given typed list. When your framework initializes or gets called it could check the xml file and build the field list for you based on the contents of the xml file. This would stop you from needing to re-compile for each "custom typed list" that you needed to create. The tradeoff would be that xml serialization isnt that fast, but once the object graph is loaded, its loaded.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 08-Jan-2005 11:59:00   

Nice idea, devildog! simple_smile

Frans Bouma | Lead developer LLBLGen Pro
hplloyd
User
Posts: 191
Joined: 29-Oct-2004
# Posted on: 11-Jan-2005 11:09:18   

Thanks,

the code will help me alot .... I dont really like the idea in creating typed lists in the designer... it just seems to me one more thing that needs to be maintained.. I prefer to have everything in code then I know that the code is all that needs to be maintained if anything changes.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 11-Jan-2005 12:24:05   

hplloyd wrote:

the code will help me alot .... I dont really like the idea in creating typed lists in the designer... it just seems to me one more thing that needs to be maintained.. I prefer to have everything in code then I know that the code is all that needs to be maintained if anything changes.

True, but on the other hand, a typed list can be something you can force onto developers to use: use that typed list, so you have to define it once. It's what you prefer I guess. simple_smile

Frans Bouma | Lead developer LLBLGen Pro