Sorting On related entity in in collection.

Posts   
 
    
Posts: 7
Joined: 10-Sep-2008
# Posted on: 15-Jun-2009 20:58:34   

I have the following Object in memory.

EmployeeEntity.PrSalaryAccountCollection

Each PrSalaryAccount has a PayTypeId. Which relates to a PayTypeEntity with the following fields. (Id, Code, Description, PrintOrder)

Each PrSalaryAccount has a GLAccountId. Which relates to a GLAccountEntity with the follwing fields. (Id, AccountNumber, Description)

When I load my grid with the EmployeeEntity.PrSalaryAccountCollection the users want them sorted in the following order. (All ascending)

PayTypeEntity.PrintOrder PayTypeEntity.Code GLAccountEntity.AccountNumber EmployeeEntity.PrSalaryAccount.Id

Using Self Service.

Thanks

Dan

rdhatch
User
Posts: 198
Joined: 03-Nov-2007
# Posted on: 15-Jun-2009 21:58:29   

Hi Dan,

In the Designer, you can edit the PrSalaryAccount & add those fields needed for sorting as Fields On Related Entities.

If fields needed for sorting are not on a directly related entity (ie, they are 2 or more relations away) - then you will need to simply create calculated readonly properties in a partial class for PrSalaryAccountEntity.

Then, to sort - use EntityProperty("field name"). So:

Dim myCalculatedField As New EntityProperty("field name")

Dim mySorter As New SortExpression
mySorter.Add(myCalculatedField)

Hope this helps!

Ryan

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005