Skip to content

Add throwOnRedundantOrderBy detection#107

Merged
SimonCropp merged 1 commit into
mainfrom
redundant-orderby-detection
Jul 24, 2026
Merged

Add throwOnRedundantOrderBy detection#107
SimonCropp merged 1 commit into
mainfrom
redundant-orderby-detection

Conversation

@SimonCropp

Copy link
Copy Markdown
Owner

Opt-in flag on UseDefaultOrderBy that throws when a query explicitly orders by exactly the same properties, sequence, and directions as the configured default ordering. Primarily useful in tests to find query ordering left over from before the default ordering was configured.

RedundantOrder walks the outermost ordering chain of the query spine and compares the collected clauses against the entity configuration. It bails out without throwing on anything that cannot be represented as configuration, such as comparer overloads or non property key selectors. Both Queryable and Enumerable ordering are handled, so nested collection ordering in Include() is checked the same way.

The flag is read from IDbContextOptions per query compilation rather than cached per DbContext type, since the interceptor is a singleton shared across contexts and a type keyed cache would be wrong when the same context type is built with different options.

Opt-in flag on UseDefaultOrderBy that throws when a query explicitly
orders by exactly the same properties, sequence, and directions as the
configured default ordering. Primarily useful in tests to find query
ordering left over from before the default ordering was configured.

RedundantOrder walks the outermost ordering chain of the query spine and
compares the collected clauses against the entity configuration. It bails
out without throwing on anything that cannot be represented as
configuration, such as comparer overloads or non property key selectors.
Both Queryable and Enumerable ordering are handled, so nested collection
ordering in Include() is checked the same way.

The flag is read from IDbContextOptions per query compilation rather than
cached per DbContext type, since the interceptor is a singleton shared
across contexts and a type keyed cache would be wrong when the same
context type is built with different options.
@SimonCropp SimonCropp added this to the 1.1.9 milestone Jul 24, 2026
@SimonCropp
SimonCropp merged commit 8ad9adf into main Jul 24, 2026
6 checks passed
@SimonCropp
SimonCropp deleted the redundant-orderby-detection branch July 24, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant