-
Notifications
You must be signed in to change notification settings - Fork 68
Closed
Description
I have an idea to get temp tables working but I’ll like to just check this would be a valid addition and not too hacky.
I would like to add an extra parameter on the type provider call something like TempTableDefinition
use cmd = new SqlCommandProvider<"
SELECT *
FROM Account a
INNER JOIN #Temp t ON a.Id = t.Id
WHERE a.Id = @Id
", ConnectionString, TempTableDefinition = "
CREATE TABLE #Temp
(
Id INT
)">(connectionString)The command and temp table create text would need to be rewritten in the design phase to a Global Temporary table (ie ##Temp) then before executing sp_describe_undeclared_parameters the create temp table query is run, afterwards the temp table can be dropped.
sp_describe_undeclared_parameters is happy to use a global temporary table
-- Setup database
DROP TABLE IF EXISTS Account
CREATE TABLE Account
(
Id INT
);
-- End setup
DROP TABLE IF EXISTS ##Temp
CREATE TABLE ##Temp
(
Id INT
);
EXECUTE sp_describe_undeclared_parameters N'
SELECT *
FROM Account a
INNER JOIN ##Temp t ON a.Id = t.Id
WHERE a.Id = @Id
'
DROP TABLE IF EXISTS ##Temp
-- Reset database
DROP TABLE IF EXISTS Account
If that all works I would also like to try and create the parameters by for the Execute by sending the temp table to the database and reading the row metadata back
DROP TABLE IF EXISTS #Temp
CREATE TABLE #Temp
(
Id INT
);
SELECT *
FROM #Temp
DROP TABLE #Temptoburger
Metadata
Metadata
Assignees
Labels
No labels