-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get output parameter value of a stored procedure using EF Core FromSql(...) is always null. #9277
Comments
We need to investigate if this is working on 2.0. We will consider patching this depending on the impact and the fix. |
Since fix for this is out in PR, removing milestone so we can discuss about patch. |
Just to clarify that this issue is in relation to SQL Server. The MySQL database provider has the same issue, but there is a known problem which prevents output parameters from being used with Connector/NET. |
Please is there a work-around for this in the interim? |
@CharlesOkwuagwu Probably the best workaround is to get the DbConnection using context.Database.GetDbConnection() and then create the command and execute it directly using DbConnection/DbCommand, etc. |
@ajcvickers Thanks, will try that option. |
Please use the below code, It works: SqlParameter spOutVar; var result = context.set().FromSql("Sp_Todo @todoCounts OUTPUT", int outputCount = int.Parse(spOutVar.Value.ToString()); Happy Coding :) |
Describe what is not working as expected.
Store procedure output parameter is not working as expected. The output value is always null.
I have an statement like this. I've removed other parameters except this
OUTPUT
param to pointing out the issue. The records are came but the the value of thisOUTPUT
parameter is null without the exception. Executing the proc in SSMS works just fine but with thisFromSql(...)
isn't doing anything for output parameter.If i add this too, then the output value coming but this is not the correct idea here. I am not seeing any exceptions.
If you are seeing an exception, include the full exceptions details (message and stack trace).
Steps to reproduce
@todoCounts VARCHAR(MAX) OUTPUT
Further technical details
EF Core version:
1.1.2
Database Provider:
1.1.2
Operating system: Windows 10
IDE: Visual Studio 2017
15.2(2643.16) release
The text was updated successfully, but these errors were encountered: