Support query-level SQL hints
Feature request
Summary:
Add support for query-level SQL hints (such as OPTION clauses) that can be appended to generated queries, for example: OPTION (RECOMPILE), OPTION (MAXDOP 1).
Motivation: Sometimes advanced performance tuning, query control, or SQL Server-specific operations require passing additional hints at the query statement level. At present, EntityFramework-Plus provides table-level hints but does not appear to expose a way to add arbitrary OPTION hints to the end of generated queries at the query level.
Proposal:
- Allow users to specify custom SQL option hints via an
WithQueryHint(...)extension or similar API that will inject the hint at the end of the SQL statement. - Example usage:
dbContext.Entities.Where(...).WithQueryHint("RECOMPILE").ToList();
Typical use cases:
- Forcing parameterized queries to recompile.
- Limiting degree of parallelism with
MAXDOP N. - Query-level hints required for advanced SQL Server tuning.
Notes:
- Please let me know if Query Hints are already supported in some form that I may have overlooked.
Hello @Vijay-Nirmal ,
Thank you for your suggestion.
I don't think we cover this scenario at the moment, but this is definitely something we will look into in early 2026.
We are currently completing our year 2025 by focusing only on documentation in December, but starting on the first day of 2026, we will put all our focus on improving our EF Plus and EFE libraries and adding some small additions like the one you proposed.
I cannot give you any approximate date, but feel free to poke us again in early 2026 if I didn't write anything back.
Best Regards,
Jon