Order by null last

2 posts, 0 answers
  1. Jacek
    Jacek avatar
    6 posts
    Member since:
    Dec 2012

    Posted 06 Oct 2014 Link to this post

    How can I order data descending with null on the end?

    In SQL I can do it:
    select r
    from some_table AS r
    order by r.some_column DESC NULLS LAST


    In OQL it's not working:
    select r
    from r.some_tableExtent
    order by r.some_column DESC NULLS LAST

    What can I do instead?
  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 07 Oct 2014 Link to this post

    At the moment i see no way to express that via OQL. It also seems to be an Oracle specific extension of SQL.
    Using LINQ, you could emulate this behavior by using
    .OrderBy(x => x.Property != null ? 0 : 1).ThenBy(x => x.Property)


    Regards,
    Thomas
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  3. DevCraft banner
Back to Top