Ordering child entity collections

Posts   
 
    
daz_oldham avatar
daz_oldham
User
Posts: 62
Joined: 20-Jul-2007
# Posted on: 29-Sep-2007 12:14:03   

Hello

Not a totally stupid question this one I hope. At the bottom of the post is a loop that I have written - it is going to populate a number of different list boxes for each ProductTypeID with it's child values (ProductTypeOptions).

This works fine, however my child objects (producttype.ProductTypeOptions) are coming back in the order they were entered into the database - I want to bring them back ordered by the field "OrderID"

I am presuming that I am going to have to change my first line to add the sort in... but how would I go about doing that?

Many thanks

Darren


ProductTypeEntity producttype = new ProductTypeEntity(m_oProduct.ProductTypeId);
            
            for (Int32 i = 0; i < producttype.ProductTypeOptions.Count; i++)
            {
                // Do something here

                for (Int32 j = 0; j < producttype.ProductTypeOptions[i].ProductTypeOptionAttributes.Count; j++)
                {
                    // Do something here
                 }

                 // Do something here
            }

Posts: 254
Joined: 16-Nov-2006
# Posted on: 29-Sep-2007 21:49:09   

Hi Darren,

This isn't a stupid question at all - in fact I have yet to see a stupid question simple_smile .

If you review the generated code you should a number of methods defined for all nested collection e.g. within the ProductTypeEntityBase class you should find a SetCollectionParametersProductTypeOptions method which takes a SortExpression object.

Reviewing your other posts I can see you know how to construct and use this type.

Cheers

Matt

daz_oldham avatar
daz_oldham
User
Posts: 62
Joined: 20-Jul-2007
# Posted on: 30-Sep-2007 22:23:22   

Brilliant Matt - found it. Will give that a try in the morning but it looks easy. Too easy!

One thing I will say is how on earth have I been a developer for ten years and managed without LLBL - it's a fantastic product and well worth the money!

Many thanks

Darren smile