The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

XPBaseCollection.Sorting Property

Gets or sets the sort settings for the current collection.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v19.2.dll

Declaration

public SortingCollection Sorting { get; set; }
Public Property Sorting As SortingCollection
public SortingCollection Sorting { get; set; }
Public Property Sorting As SortingCollection

Property Value

Type Description
SortingCollection

The SortingCollection that specifies the sort order for the collection.

Property Value

Type Description
SortingCollection

The SortingCollection that specifies the sort order for the collection.

Remarks

Calling the SortingCollection's Add, Remove and Clear methods is not allowed. To sort a collection, a new SortingCollection object must be created and assigned to the Sorting property.


XPCollection<MyObject> xpCollection1 = new XPCollection<MyObject>();
SortingCollection sorting = new SortingCollection();
sorting.Add(new SortProperty("PropertyA", DevExpress.Xpo.DB.SortingDirection.Ascending));
xpCollection1.Sorting = sorting;
...

SortingCollection newSorting = new SortingCollection();
newSorting.Add(new SortProperty("PropertyB", DevExpress.Xpo.DB.SortingDirection.Ascending));
xpCollection1.Sorting = newSorting;

To learn more, see Sorting Basics.

Note

For performance reasons, we recommend that you not use the JoinOperand in sort properties, as this significantly increases the number of queries sent to the server.

Examples

The following example demonstrates how to sort a collection (xpCollectionPerson) in ascending order against a 'Name' field.

using DevExpress.Xpo;
using DevExpress.Xpo.DB;

SortingCollection sortCollection = new SortingCollection();
sortCollection.Add(new SortProperty("Name", SortingDirection.Ascending));
xpCollectionPerson.Sorting = sortCollection;
See Also