How I can order desc nulls to last on entity view like this query ?

Posts   
 
    
shaloml
User
Posts: 3
Joined: 25-Jun-2009
# Posted on: 25-Jun-2009 10:12:37   

How I can order desc **nulls to last **on entity view like this query ? my database is oracle.

select  t.Last_Visit_Date from patients_index_v t
order by  t.Last_Visit_Date  desc nulls last; 
Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 25-Jun-2009 10:49:28   
shaloml
User
Posts: 3
Joined: 25-Jun-2009
# Posted on: 25-Jun-2009 11:00:42   

Hi Walaa, Is there any way to tell to LLBLGEN to create queries with instant nulls last I'm working with FetchTypedView. Can I set nulls last behavior with LLGLGEN.

Thank you.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 25-Jun-2009 11:45:13   

You may derive from the SortExpression and override the ToQueryText method.

e.g. cn be found here: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=14414

shaloml
User
Posts: 3
Joined: 25-Jun-2009
# Posted on: 25-Jun-2009 12:42:22   

Thank you! Overriding SortExpression solves our problem! simple_smile

 public class DerivedSortExpression : SortExpression
    {
        public override string ToQueryText(ref int uniqueMarker, bool aliasesForExpressionsAggregates)
        {
            return base.ToQueryText(ref uniqueMarker, aliasesForExpressionsAggregates).Replace("DESC","DESC NULLS LAST").Replace("ASC","ASC NULLS FIRST");
        }
    }