Skip to content
Advertisement

How do I retrieve scope identity with ExecuteNonQuery?

My project is using .NET Core 3.1 and I have my stored procedures executing in my repository class. I want to insert and return the scope identity(the id of the record that just inserted UserNumber) so I can use it for another stored proc within this same method. The problem I have here is that parameters[1].Value value is returning zero.

Here is an abbreviation of my stored proc:

Here is a sample of my repository

How do I assign the scope identity to result2?

Advertisement

Answer

Should be something like:

and

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement