Improve preprocessor extensibility

Open
#39,418 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
databases

Research direction

Start with QueryTranslationPreprocessor.Process and compare the relational and Cosmos preprocessors named in the issue to trace the existing phase order and query-root specialization. Then read the provider API conventions and relevant preprocessing tests; done means phase ordering, override tree shapes, existing overrides, and default behavior are covered by tests, with provider-facing documentation for each supported boundary.

Written by the indexing model from the issue text.

Description

area-query needs-design

Database providers can already supply an IQueryTranslationPreprocessorFactory, derive from QueryTranslationPreprocessor or RelationalQueryTranslationPreprocessor, and override Process. There are also narrower extension points such as NormalizeQueryableMethod and ProcessQueryRoots. This issue is about improving that existing provider extension model, not introducing query interception.

Most preprocessing steps are nevertheless constructed and invoked directly inside QueryTranslationPreprocessor.Process. A provider can easily add work before or after the entire base implementation, but inserting or replacing a transformation between the remaining steps can require copying the base implementation and depending on internal visitors.

For example, a provider that needs to transform the navigation-expanded tree before the common query optimizations cannot currently override that individual phase. Copying Process makes the provider responsible for preserving the ordering of normalization, null-check removal, navigation expansion, and optimization, and for incorporating future changes to that sequence.

Current implementation:

Describe the solution you'd like

Expose narrowly scoped, overridable preprocessing phases where database providers need to customize the pipeline, while keeping the common sequencing and required transformations in the base implementation.

The precise API needs design. Prefer protected virtual phase methods and reuse of existing factories/dependencies over requiring providers to copy Process or introducing a general-purpose visitor-registration framework. Document the expression shape and invariants at each supported extension point, especially around normalization and navigation expansion.

Acceptance criteria
  • A derived provider preprocessor can insert a transformation at a supported intermediate boundary, such as after navigation expansion and before common optimization, without reproducing the base processing sequence.
  • A provider can specialize a supported phase while reusing the common behavior of that phase where appropriate.
  • Existing overrides of Process, NormalizeQueryableMethod, and ProcessQueryRoots retain their behavior.
  • Core and relational preprocessors compose correctly; existing Cosmos and relational query-root specialization remains intact.
  • Tests verify phase ordering, the tree shape visible to overrides, and unchanged behavior when no provider customization is supplied.
  • Provider-facing API documentation describes the supported boundaries and required invariants. Newly exposed provider APIs follow the repository's provider API conventions.
Scope and related work
  • This is a database-provider extension surface, not an application interceptor or an additive third-party plugin API.
  • This does not request a hook before parameter extraction or funcletization.
  • #28505 implemented LINQ expression interception; that is not a substitute for provider customization of intermediate preprocessing phases.
  • #19748 concerns interception of SQL generation and is separate from this request.
  • Combining visitors to reduce traversals is a separate performance task.
Dominant language
C#
Stars
14.8k
Forks
3.5k
Avg merge
3d 7h
Merged PRs (30d)
182

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/efcore

All issues in dotnet/efcore

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.