Business Logic Framework - How To:
The process of specifying a sort multi column sort on multiple joined
objects is very similar to the process of specifying a single column sort.
In this sample code below we create a join between the Orders and Customers
object, and sort the result set by Orders.OrderAmount in the Descending order
and the Customers.FirstName in the Ascending order.
 |
This sample code below uses new Set method
introduced on the BaseField class that allows you to set the
Sort and SortPosition property values in one line. However, you
can still access or set the Sort and SortPosition properties
directly if you prefer. |
| 1 |
// This sample will sort a joined result set by two fields. The Orders will be combined with
|
| 2 |
// Customers, and sorted by OrderAmount Descending and FirstName Ascending.
|
| 3 |
using
(Orders order =
new Orders()) |
| 4 |
{ |
| 5 |
order.Join_CustomerID_Customers_Parent(); |
| 6 |
// The following line shows an alternate way to set the Sort and SortPosition property of a field.
|
| 7 |
// You can still use the Sort and SortPosition properties directly if you prefer.
|
| 8 |
order.OrderAmount.Set(SortTypes.Descending, 1); |
| 9 |
order.CustomerID_Customers_Parent.FirstName.Set(SortTypes.Ascending, 2); |
| 10 |
order.Find(); |
| 11 |
if (order.AffectedRecords > 0) |
| 12 |
{ |
| 13 |
this.dataGridView1.DataSource = order.ResultSet; |
| 14 |
this.dataGridView1.DataMember = order.GetResultSetName(); |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 1 | ' This sample will sort a joined result set by two fields. The Orders will be combined with |
| 2 | ' Customers, and sorted by OrderAmount Descending and FirstName Ascending. |
| 3 | Using order As New Orders() |
| 4 | order.Join_CustomerID_Customers_Parent() |
| 5 | ' The following line shows an alternate way to set the Sort and SortPosition property of a field. |
| 6 | ' You can still use the Sort and SortPosition properties directly if you prefer. |
| 7 | order.OrderAmount.[Set](SortTypes.Descending, 1) |
| 8 | order.CustomerID_Customers_Parent.FirstName.[Set](SortTypes.Ascending, 2) |
| 9 | order.Find() |
| 10 | If order.AffectedRecords > 0 Then |
| 11 | Me.dataGridView1.DataSource = order.ResultSet |
| 12 | Me.dataGridView1.DataMember = order.GetResultSetName() |
| 13 | End If |
| 14 | End Using |
| 15 | |