public void JoinWithArithmeticExpressionOrderByCalulatedColumn() { CustomerCollection collection = new CustomerCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); string orderAlias = ""; switch (collection.es.Connection.ProviderSignature.DataProviderName) { case "EntitySpaces.MSAccessProvider": orderAlias = "<'TotalSales'>"; break; default: orderAlias = "TotalSales"; break; } // Notice I create a calulated columns based on the TotalSales, // then Order by it descending CustomerQuery cust = new CustomerQuery("c"); OrderQuery order = new OrderQuery("o"); OrderItemQuery item = new OrderItemQuery("oi"); cust.Select(cust.CustomerName, (item.Quantity * item.UnitPrice).Sum().As("TotalSales")); cust.InnerJoin(order).On(order.CustID == cust.CustomerID); cust.InnerJoin(item).On(item.OrderID == order.OrderID); cust.GroupBy(cust.CustomerName); cust.OrderBy(orderAlias, esOrderByDirection.Descending); Assert.IsTrue(collection.Load(cust)); Assert.AreEqual(6, collection.Count); }