Business Logic Framework - How To:
The process of specifying a sort during Find method is quite simple.
- Set the Sort property of the field to Ascending or Descending from the Enumeration.
- Set the SortPosition property of the field to a number starting with 1. This decides in what order are the fields used in the sort expression.
 |
Starting version 3.5 It is not longer required to set the SortPosition property if only one field is being included in the Sort. |
| 1 |
// In this sample we will sort the Orders by OrderAmount in the Descending Order. |
| 2 |
using (Orders o = new Orders()) |
| 3 |
{ |
| 4 |
o.OrderAmount.Sort = SortTypes.Descending; |
| 5 |
// set the position to a number. This number determines which field used first for sorting |
| 6 |
o.OrderAmount.SortPosition = 1; // This is not required if only one field is being sorted on (from v3.5 and above) |
| 7 |
|
| 8 |
o.Find(); |
| 9 |
if (o.AffectedRecords > 0) |
| 10 |
{ |
| 11 |
this.dataGridView1.DataSource = o.ResultSet; |
| 12 |
this.dataGridView1.DataMember = o.GetResultSetName(); |
| 13 |
} |
| 14 |
} |
| 15 |
|
| 1 |
' In this sample we will sort the Orders by OrderAmount in the Descending Order. |
| 2 |
Using o As New Orders() |
| 3 |
o.OrderAmount.Sort = SortTypes.Descending |
| 4 |
' set the position to a number. This number determines which field used first for sorting |
| 5 |
o.OrderAmount.SortPosition = 1 ' This is not required if only one field is being sorted on (from v3.5 and above) |
| 6 |
o.Find() |
| 7 |
If o.AffectedRecords > 0 Then |
| 8 |
Me.dataGridView1.DataSource = o.ResultSet |
| 9 |
Me.dataGridView1.DataMember = o.GetResultSetName() |
| 10 |
End If |
| 11 |
End Using |
| 12 |
|