From 832723cae7e78abcc1617738b0c926ae12a9c104 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 9 Mar 2026 07:24:17 +0000 Subject: [PATCH 1/2] docs: document TempTableDefinitions and TableVarMapping parameters (#350) Add the two missing SqlCommandProvider parameters to the configuration table and add new subsections explaining each feature with usage examples: - TempTableDefinitions: explains that the provider generates a LoadTempTables method and a nested record type for each temp table; shows the declare/populate/execute pattern. - TableVarMapping: explains when and why it is needed (inline TVP queries where sp_describe_undeclared_parameters cannot infer the UDT), gives the key=value format, and cross-references the FAQ for the duplicate- parameter limitation. Closes #350 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/content/configuration and Input.fsx | 43 +++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/docs/content/configuration and Input.fsx b/docs/content/configuration and Input.fsx index e621636a..f2c98f56 100644 --- a/docs/content/configuration and Input.fsx +++ b/docs/content/configuration and Input.fsx @@ -20,6 +20,8 @@ SqlCommandProvider parameters AllParametersOptionalfalsetrue/false ResolutionFolderThe folder that contains the project or script.Valid file system path. Absolute or relative. DataDirectoryThe name of the data directory that replaces |DataDirectory| in connection strings. The default value is the project or script directory.Valid file system path. + TempTableDefinitions""Semicolon-separated CREATE TABLE #Temp … statements. Allows queries that reference temporary tables. + TableVarMapping""Maps inline table variables to existing user-defined table types, e.g. @tvp1=dbo.MyTableType; @tvp2=dbo.OtherType. @@ -381,7 +383,46 @@ do use cmd = new AdventureWorks2012.dbo.MyProc(connStr) cmd.Execute([ T(myId = 2); T(myId = 1) ]) |> printfn "%A" -(** +(** +### Temp tables (`TempTableDefinitions`) + +When a query references temporary tables (e.g. `#Temp`), the type provider needs to know their schema at +design time. Use `TempTableDefinitions` to supply the `CREATE TABLE #…` statement(s) (semicolon-separated). + +At runtime, the generated `LoadTempTables` method must be called **before** `Execute` to populate the +temp tables. They are automatically dropped when the `SqlConnection` is closed or the command is disposed. +*) + +// Declare a temp-table schema; the provider generates a LoadTempTables method and a nested record type. +type TempTableExample = + SqlCommandProvider< + CommandText = "SELECT Id, Name FROM #Items", + ConnectionStringOrName = connStr, + TempTableDefinitions = "CREATE TABLE #Items (Id INT NOT NULL, Name NVARCHAR(100) NULL)"> + +(** +Usage (connection must be open and passed to the command constructor): + + use conn = new SqlConnection(connStr) + conn.Open() + use cmd = new TempTableExample(conn) + cmd.LoadTempTables(Items = [TempTableExample.Items(Id = 1, Name = Some "foo")]) + cmd.Execute() |> Seq.iter ... + +### Inline TVPs via `TableVarMapping` + +Normally `SqlCommandProvider` discovers TVP types automatically when the query calls a stored procedure. +For **inline queries** that reference a table-valued parameter, the server cannot infer the user-defined +table type and the provider needs a hint. + +Use `TableVarMapping` to map each table-variable parameter to its user-defined table type. The format is +a semicolon-separated list of `@param=schema.TypeName` pairs: + + TableVarMapping = "@tvp1=dbo.MyTableType; @tvp2=dbo.OtherType" + +Note: if you need to use the same parameter name more than once in an inline query, declare the type +explicitly in `TableVarMapping` — see the [FAQ](faq.html) for details. + ### Stored procedures Command types generated by `SqlProgrammabilityProvider<...>` largely have same interface with exceptions: From 0637e2f942b60c149a45c7318d9221029d940813 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 9 Mar 2026 07:29:22 +0000 Subject: [PATCH 2/2] ci: trigger checks