Sorting Data

In this article we'll:

  • Sort by Ship City
  • Show how to make the sort descending
public ShowOrders()
{
     From = Orders;
     Where.Add(Orders.ShipCity.IsEqualTo("London").Or(
           Orders.ShipCity.IsEqualTo("Madrid")));
     Where.Add(Orders.ShipName.IsDifferentFrom(""));

     OrderBy.Add(Orders.ShipCity);
     OrderBy.Add(Orders.OrderDate, SortDirection.Descending);

} 

You can also sort using an existing index from the table - the syntax is a bit different, you will need to choose
from the existing entity's indexes (their names are prefixed with SortBy). For example:

public ShowOrders()
{
     From = Orders;
     Where.Add(Orders.ShipCity.IsEqualTo("London").Or(
           Orders.ShipCity.IsEqualTo("Madrid")));
     Where.Add(Orders.ShipName.IsDifferentFrom(""));

-    OrderBy.Add(Orders.ShipCity);
     OrderBy = Orders.SortByCustomerID;

} 


Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com