fsprojects / fsprojects/FSharp.Data.SqlClient
SqlProgrammabilityProvider with Record based User-Defined Table Types
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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