Need for an RPC friendly query output
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
Research direction
Start at the ToQueryString entry point and trace the SQL Server query-output path, paying attention to how parameter declarations and query text are assembled. Done means a separate output view can represent the executed query as an sp_executesql RPC-style wrapper while retaining the existing readable output.
Written by the indexing model from the issue text.
Description
EF runs parameterised queries against SQL Server, using RPC statements.
The current output of ToQueryString outputs the query being run but prefixes the query with the parameter declarations
DECLARE @foo int = 99
SELECT foo FROM dbo.myTable WHERE id = @foo
This can be copied and run in Management Studio of Azure Data Studio, but its not replicating the query run by EF because the query text is different and the parameter is not being passed in as a parameter to an RPC call. Its just executing a single batch including the parameter.
The way to solve this is to 1. get SSMS to be able to run RPC statements (it sort for can for Always Encrypted connections but that won't work here) 2. output the text as
DECLARE @foo int = 99
exec sp_executesql N'SELECT foo FROM dbo.myTable where id = @foo', N'@foo int', @foo
Whilst the outer text looks different this is just a wrapper and doesn't do anything. The query being executed really is whats passed to sp_executesql which is matches what EF has executed.
This is what SQL profiler has done for years.
It makes the query less readable in Management Studio and thus having a second output that provides this view if people are caring about performance and understanding the query plans that are being used by the EF queries.
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 134
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/efcore
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
customer-reported
Difficulty 5/5 Over a week Newbie friendliness 38/100
-
area-cosmos area-vector-search
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-cosmos
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-tools needs-design
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100