Indexes Ascending or Descending
Mar 25, 2024
We use the indexes for performance. We can index sorting. That is like ORDER BY word. This feature is crucial to big data.
The index default is ascending.
Examples (My examples with Fluent API);
This is ascending and also composite indexing.
modelBuilder.Entity<Customer>().
HasIndex(c => new { c.FirstName, c.LastName, c.DateOfBirth },
"IX_Names_Ascending");
This is descending and also composite indexing.
modelBuilder.Entity<Customer>()
.HasIndex(c => new { c.FirstName, c.LastName, c.DateOfBirth },
"IX_Names_Descending")
.IsDescending();
Good luck.