Query: AsSplitQuery with FromSql Containing output DbParameter

Open
#22,498 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
database

Research direction

Start by reviewing issues #11370 and #22483, then read the discussion on pull request #22485 for the proposed handling of output and input-output DbParameters. Trace how split queries create additional commands. Done means the first query updates the user-supplied parameter while additional queries use compatible cloned parameters.

Written by the indexing model from the issue text.

Description

area-query customer-reported

#11370 when DbParameter direction is something other than Input

Also see #22483

The main issue, same DbParameter which user supplied to us cannot be added to multiple DbCommand.
For Input parameter, we added fix which is just to clone the DbParameter so that each command gets new DbParameter with same info.
Above fix is not possible for parameters which are output or inputoutput since the value updated after executing db command need to be reflected in the user created DbParameter which we have no way of doing.
Based on conversation https://github.com/dotnet/efcore/pull/22485#discussion_r486678848 and suggestion by @bricelam
We can actually make it work, if we know when to clone for additional queries. In that case, we will send first query with user supplied DbParameter and additional queries with cloned parameters. So first query will always update value and give back correct values to user.

Dominant language
C#
Stars
14.8k
Forks
3.4k
Avg merge
2d 5h
Merged PRs (30d)
134

Contributor guide

Open the contributing guide

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.