IOrderable<TModel>.ThenByDescending<TKey>(Func<TModel, TKey> keySelector) Method
.NET Standard 2.x
Performs a subsequent ordering of the model objects in the current sortable object in descending order according to a key.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
IOrderable<TModel> ThenByDescending<TKey>(Func<TModel, TKey> keySelector);
Type Parameters
TKey
The data type of the key.
Parameters
keySelector System.Func<TModel, TKey>
A function to extract a key from a model object.
Returns
SnapObjects.Data.IOrderable<TModel>
Returns the current IOrderable object which can be used to add other sorting conditions or execute sort.
Examples
The following code example sets the primary and secondary sorting rules and then sorts the data according to the rule in the descending order.
using Appeon.ApiDoc.Models.School;
using DWNet.Data;
namespace Appeon.ApiDoc.IOrderableExamples
{
public class ThenByDescendingExample
{
private readonly SchoolContext _context;
public ThenByDescendingExample(SchoolContext context)
{
_context = context;
}
public void Example()
{
// Retrieves data for ModelStore
var courses = new ModelStore<Course>();
courses.Retrieve(_context);
// Sets the primary sorting rule (first by DepartmentID)
var order = courses.OrderBy(m => m.DepartmentID);
// Sets the secondary sorting rule (then by CourseID in descending order)
var secondOrder = order.ThenByDescending(m => m.CourseID);
// Sorts the data
secondOrder.Sort();
}
}
}
Example Refer To
Model Class: Course
Applies to
.NET Standard
2.x