Descending sort order, with null values at top

Posts   
 
    
Eltrab
User
Posts: 10
Joined: 24-Sep-2007
# Posted on: 15-Oct-2007 01:51:12   

Hi there,

I wish to sort an entity collection by a date column, descending, but with null values at the top. What is the easiest way to achieve this? In SQL I'd use a case statement in my ORDER BY clause.

I am using the adapter model with LLBLGen Pro 2.5.

Thanks for your time.

Cheers, Andrew

jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 15-Oct-2007 05:25:16   

2.5 supports case statements. so you should be able to create a custom EntityField2 using the case statement as a expression of the field. then add this to the sortexpression object.

another alternative. filter the null entities into a entity collection. filter the non-null entities into another collection. then add the non-nulls to the null collection.

Eltrab
User
Posts: 10
Joined: 24-Sep-2007
# Posted on: 15-Oct-2007 08:19:17   

Cool, thanks!