question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make optional arguments for Stored Procedures optional in the generated .NET method

See original GitHub issue

Provide steps to reproduce

I have a stored procedure defined as follows:

create procedure dbo.SpMapGet(
	@NodeId int,
	@Debug int = null
) as begin
     // ...
end

When I create the model for this using the version detailed below, the generated method has the following signature:

public virtual async Task<TResult> SpMapGetAsync(
    int? NodeId,
    int? Debug,
    OutputParameter<int> returnValue = null,
    CancellationToken cancellationToken = default)
{
    // ...
}

What I would like to see is Debug becoming an optional parameter there, too, just like in the SQL statement:

public virtual async Task<TResult> SpMapGetAsync(
    int? NodeId,
-    int? Debug,
+    int? Debug = null,
    OutputParameter<int> returnValue = null,
    CancellationToken cancellationToken = default)
{
    // ...
}

Is this something that you would consider implementing?

Provide technical details

  • Exact Visual Studio version: Visual Studio 2022 17.6.5

  • EF Core Power Tools version: 2.5.1544

  • Database engine: SQL Server

  • EF Core version in use: EF Core 7

  • Is Handlebars used: no

  • Is T4 used: no

  • Is .dacpac used: ?

Issue Analytics

  • State:closed
  • Created 2 months ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
0livercommented, Aug 8, 2023

Thanks for looking into this, @ErikEJ. It’s a pitty, there’s no info about this.

0reactions
ErikEJcommented, Aug 8, 2023

You are welcome.

If you like my free tools, I would be very grateful for a rating or review on Visual Studio Marketplace or even a one-time or monthly sponsorship

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optional parameters in SQL Server stored procedure
You can declare it like this: CREATE PROCEDURE MyProcName @Parameter1 INT = 1, @Parameter2 VARCHAR (100) = 'StringValue', ...
Read more >
Optional Parameters in Stored Procedure in SQL
In this article I will demonstrate how to use optional parameters in a Stored Procedure in SQL.
Read more >
Optional vs Required parameters in Stored Procedures
Fortunately, it's pretty easy to make some parameters required and others optional. You simply give them a default value. 1. 2. 3. 4....
Read more >
Handling optional parameters in stored procedure
I have a stored procedure, say "Test" with an optional parameter @Param1 int = NULL. In the procedure, the value of @Param1 is...
Read more >
Create stored procedure that accepts optional parameter in ...
To create optional parameter in stored procedure, we set the parameter value to NULL while creating a stored procedure. CREATE PROCEDURE [dbo].
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found