fsprojects / fsprojects/FSharp.Data.SqlClient

SqlProgrammabilityProvider with Record based User-Defined Table Types

Open
#258 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

blocked improvement
Dominant language
F#
Stars
206
Forks
66
PR merge metrics
No merged PRs in 30d

Description

Currently the User-Defined Table Types are classes. Could a config option be added to allow them to be records.

Sql Setup:

--DROP PROCEDURE InsertTypeIntoTable1
--DROP TYPE dbo.Type1
--DROP TABLE Table1
--GO

CREATE TABLE [dbo].[Table1](
    Id INT IDENTITY(1,1) NOT NULL,
    Name NVARCHAR(50) NOT NULL)
GO

CREATE TYPE dbo.Type1 AS TABLE(
    Name NVARCHAR(50) NOT NULL
)
GO

CREATE PROCEDURE InsertTypeIntoTable1
    @Data dbo.Type1 READONLY
AS
BEGIN
    SET NOCOUNT ON;
    INSERT  Table1(Name)
    SELECT  Name
    FROM    @Data
END
GO

Test Script:

#r "./packages/FSharp.Data.SqlClient/lib/net40/FSharp.Data.SqlClient.dll"

open FSharp.Data

[<Literal>]
let connectionString =
    @"Data Source=.;Initial Catalog=Temp;Integrated Security=True"

type Db = SqlProgrammabilityProvider<connectionString>

let cmd = new Db.dbo.InsertTypeIntoTable1(connectionString)

// Type1 is a class
type Type1 = Db.dbo.``User-Defined Table Types``.Type1

cmd.Execute([ Type1("Value 1"); Type1("Value 2") ]) |> ignore

However it would be great if the last line could be used as so (maybe with a config?):

cmd.Execute([ { Name = "Value 1" }; { Name = "Value 2" } ]) |> ignore

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the SQL setup and F# test script from the issue with SqlProgrammabilityProvider. Inspect how the provider exposes User-Defined Table Types and how Execute accepts their generated class values. Done means a configuration option allows record-based values so the shown record list can be passed to InsertTypeIntoTable1.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.