This section describes how you can order the results generated by RQL using the OrderBy and OrderByDescending methods.

1. Ordering Ascending

Order all Employees Ascending by the FName Property
                var t9 = manager.AsAlias<Employee>();
                var countries = new From( typeof( Employee ) ).As( t9 )
                                .OrderBy( t9.Fname )
                                .SelectNew( ( ) => 
                                                    t9.Fname 
                                            ).Execute( );

//Generated Sql
SELECT  [t0].[fname] AS [R0] FROM  [employee] [t0]  ORDER BY [t0].[fname] ASC

1. Ordering Descending

Order all Employees Descending by the FName Property
                var t9 = manager.AsAlias<Employee>();
                var countries = new From( typeof( Employee ) ).As( t9 )
                                .OrderByDescending( t9.Fname )
                                .SelectNew( ( ) => 
                                                    t9.Fname 
                                            ).Execute( );

//Generated Sql
SELECT  [t0].[fname] AS [R0] FROM  [employee] [t0]  ORDER BY [t0].[fname] DESC

Note Multiple order by Directions is not supported yet.

Last edited Feb 3, 2010 at 3:51 PM by ahmedsalako, version 3

Comments

No comments yet.