Indexes Ascending or Descending

Taşkın Binbir
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.

--

--

Taşkın Binbir
Taşkın Binbir

Written by Taşkın Binbir

Computer Engineer, Software Developer

No responses yet