I've got what I'm sure is a basic question regarding sorts on queries.
I have two tables: Orders (OrderId, OrderDate, CustomerId) and Customer (CustomerId, CustomerName) which are joined by CustomerId.
I would like to get a list of orders sorted by CustomerName and then OrderDate. In sql this would be trivial...
SELECT * FROM Orders
WHERE Orders.CustomerId = Customer.CustomerId
ORDER BY Customer.CustomerName, Orders.OrderDate
However it doesnt seem to be as obvious in OQL. I have 2 entities defined, Orders and Customers. There is a relation defined between the two on CustomerId with the Customer table as the parent.
RdbQuery query = new RdbQuery(typeof(Orders))
EntitySubquery subQuery = query.AddSubQuery(EntityRelations.CustomerToOrders)
subquery.AddOrderBy(Customer.CustomerName)
query.AddOrderBy(Orders.OrderDate)
pm.GetEntities<Orders>(query)
The above gives me a list of Order entities, however they are sorted by OrderDate and then CustomerName. I would like them sorted by CustomerName and *then* OrderDate. Where am i going wrong? :)
Thanks in advance!
Edited by JonF - 26-Jan-2009 at 4:34pm