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.

Bug with new experimental feature of Multiple Result Sets from a stored procedure

See original GitHub issue

I am trying the new experimental feature of Multiple Result Sets from a stored procedure. This worked great for me with a couple of small things below.

Steps to reproduce

I created a simple stored procedure that returned 3 different result sets back in one call. No input parameters.

  • The generated code did not include the Dapper package for me–no big deal, just unexpected. This may be out-of-band and just need to be documented.
  • I included a non-multi stored procedure with the test and it happens to include an nvarchar in it’s result set. This fails code generation if the experimental feature is on, but works if it is off. Unable to get result set shape for PROCEDURE 'dbo.Blahblahblah' Operand type clash: nvarchar is incompatible with Blahblahblah
  • I was a but surprised that this returns multiple List<> variables. This will not be a problem for the code I write, but if someone has a very large result set, this may pose a memory issue. Normally a DataReader of some sort is used.

Further technical details

EF Core version in use: EF Core 6

EF Core Power Tools version: 2.5.863.0

Database engine: SQL Server 2019 Standard Edition

Visual Studio version: Visual Studio 2022

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
JimF42commented, Dec 16, 2021
  1. Understood
  2. Well, actually, it wasn’t what I thought it was. This database is new to me and I just “picked one”. Turns out it passes in a UserDefinedTableType that does not actually have an nvarchar in it! See sample code below.
  3. Understood. Again, it’s not a concern for me personally as I typically spin off these kinds of result sets to List<>s anyway–you’ve just done it for me.
/****** Object:  UserDefinedTableType [dbo].[ChecksAdd]    Script Date: 12/16/2021 2:33:34 PM ******/
Create Type dbo.ChecksAdd As Table
(
    ProcessID int           Not Null,
    HistoryID int           Not Null,
    CheckID   int           Not Null,
    CheckDate datetime2(7)  Not Null,
    CheckRaw  numeric(9, 3) Not Null,
    Primary Key Clustered (
                              ProcessID Asc,
                              HistoryID Asc
                          )
    With (Ignore_Dup_Key = Off)
)
Go
Create Procedure dbo.ReturnDataTypes @tp ChecksAdd ReadOnly
As
Begin
    Select 1
End
Go
Declare @RDT ChecksAdd
Exec dbo.ReturnDataTypes @RDT
0reactions
JimF42commented, Dec 17, 2021

@ErikEJ Personally, I’m fine with not being able to have the SchemaOnly table valued parameters.

I have better ways of dealing with passing in tables of data to a stored procedure (better from the standpoint of having a c# app calling the sproc at least). As long as there’s not to much volume of data I usually pass in a JSON string and have SQL decode the JSON. Even then, I only typically do that for things like when I have a variable, but small number, of items I need to write a filter for. Say the user wants to filter on certain product numbers and they get to choose which ones, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support multiple result sets from a SQL Server Stored ...
Create a stored procedure that issues two different result sets. Run this tool to bring it in and you will only see the...
Read more >
Using JPA with stored procedures that return multiple result ...
Is it possible to handle multiple result sets having different columns from a stored procedure in SQL Server using JPA?
Read more >
Stored proc returning multiple result sets - I need just ONE!
The problem, for me, at least, occurs when the stored procedure returns multiple result sets. Sometimes upwards of 25 result sets are returned....
Read more >
Stored Procedures with Multiple Result Sets - EF6
In order to get multiple result sets working we need to drop to the ObjectContext API by using the IObjectContextAdapter interface. Once we ......
Read more >
Stored procedures and multiple result sets in T-SQL
In T-SQL it's just impossible to access multiple result sets if stored procedure returns them.
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