{"id":15002757,"url":"https://github.com/fsprojects/fsharp.data.sqlclient","last_synced_at":"2025-05-16T10:05:57.308Z","repository":{"id":10576941,"uuid":"12784631","full_name":"fsprojects/FSharp.Data.SqlClient","owner":"fsprojects","description":"A set of F# Type Providers for statically typed access to MS SQL database","archived":false,"fork":false,"pushed_at":"2023-12-06T03:23:43.000Z","size":49645,"stargazers_count":204,"open_issues_count":85,"forks_count":69,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-12T03:53:09.541Z","etag":null,"topics":["f-sharp","sql","sqlserver","t-sql","typeprovider"],"latest_commit_sha":null,"homepage":"http://fsprojects.github.io/FSharp.Data.SqlClient/","language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fsprojects.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2013-09-12T13:40:13.000Z","updated_at":"2025-01-12T00:00:36.000Z","dependencies_parsed_at":"2023-01-11T19:15:19.431Z","dependency_job_id":"5d0997a8-32a5-4ab6-b770-bde4e7ea01d6","html_url":"https://github.com/fsprojects/FSharp.Data.SqlClient","commit_stats":null,"previous_names":["dmitry-a-morozov/fsharp.data.sqlcommandtypeprovider","fsprojects/fsharp.data.experimental.sqlcommandprovider"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fsprojects%2FFSharp.Data.SqlClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fsprojects%2FFSharp.Data.SqlClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fsprojects%2FFSharp.Data.SqlClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fsprojects%2FFSharp.Data.SqlClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fsprojects","download_url":"https://codeload.github.com/fsprojects/FSharp.Data.SqlClient/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248514209,"owners_count":21116899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["f-sharp","sql","sqlserver","t-sql","typeprovider"],"created_at":"2024-09-24T18:52:16.303Z","updated_at":"2025-05-16T10:05:57.303Z","avatar_url":"https://github.com/fsprojects.png","language":"F#","readme":"# FSharp.Data.SqlClient - Type providers for Microsoft SQL Server\n\nThis library exposes SQL Server Database objects in a type safe manner to F# code, by the mean of [Type Providers](https://docs.microsoft.com/en-us/dotnet/fsharp/tutorials/type-providers/)\n\nYou can reference it in F# Interactive that ships with Visual Studio\n```fsharp\n#r \"nuget: FSharp.Data.SqlClient\"\nopen FSharp.Data\nopen FSharp.Data.SqlClient\nlet [\u003cLiteral\u003e] connectionString = \"Server=.;Database=AdventureWorks2012;Trusted_Connection=True;\"\ntype MyCommand = SqlCommandProvider\u003c\"\"\"\nselect \n\tdata.a \nfrom \n\t(select 1 a union all select 2 union all select 3) data\nwhere\n\tdata.a \u003e @data \n    \"\"\", connectionString\u003e;;\n\n(new MyCommand(connectionString)).Execute(data=1) \n|\u003e Seq.toArray\n|\u003e printfn \"%A\"\n```\n\n`dotnet fsi` is not supported yet.\n\n## Quick Links\n* [Documentation](http://fsprojects.github.io/FSharp.Data.SqlClient/)\n* [Release Notes](RELEASE_NOTES.md)\n* [Contribution Guide Lines](CONTRIBUTING.md)\n* [Gitter Chat Room](https://gitter.im/fsprojects/FSharp.Data.SqlClient)\n* [FSharp.Data.SqlClient on nuget.org](https://www.nuget.org/packages/FSharp.Data.SqlClient/)\n## Type Providers\n\n### SqlCommandProvider \n\nProvides statically typed access to the parameters and result set of T-SQL command in idiomatic F# way \u003csup\u003e(*)\u003c/sup\u003e.\n\n```fsharp\nopen FSharp.Data\n\n[\u003cLiteral\u003e]\nlet connectionString = \"Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True;TrustServerCertificate=true\"\n\n// The query below retrieves top 3 sales representatives from North American region with YTD sales of more than one million.\n\ndo\n    use cmd = new SqlCommandProvider\u003c\"\n        SELECT TOP(@topN) FirstName, LastName, SalesYTD \n        FROM Sales.vSalesPerson\n        WHERE CountryRegionName = @regionName AND SalesYTD \u003e @salesMoreThan \n        ORDER BY SalesYTD\n        \" , connectionString\u003e(connectionString)\n\n    cmd.Execute(topN = 3L, regionName = \"United States\", salesMoreThan = 1000000M) |\u003e printfn \"%A\"\n```\noutput\n```fsharp\nseq\n    [(\"Pamela\", \"Ansman-Wolfe\", 1352577.1325M);\n     (\"David\", \"Campbell\", 1573012.9383M);\n     (\"Tete\", \"Mensa-Annan\", 1576562.1966M)]\n```\n\n### SqlProgrammabilityProvider \n\nExposes Tables, Stored Procedures, User-Defined Types and User-Defined Functions in F# code.\n\n```fsharp\ntype AdventureWorks = SqlProgrammabilityProvider\u003cconnectionString\u003e\ndo\n    use cmd = new AdventureWorks.dbo.uspGetWhereUsedProductID(connectionString)\n    for x in cmd.Execute( StartProductID = 1, CheckDate = System.DateTime(2013,1,1)) do\n        //check for nulls\n        match x.ProductAssemblyID, x.StandardCost, x.TotalQuantity with \n        | Some prodAsmId, Some cost, Some qty -\u003e \n            printfn \"ProductAssemblyID: %i, StandardCost: %M, TotalQuantity: %M\" prodAsmId cost qty\n        | _ -\u003e ()\n```\noutput\n```fsharp\nProductAssemblyID: 749, StandardCost: 2171.2942, TotalQuantity: 1.00\nProductAssemblyID: 750, StandardCost: 2171.2942, TotalQuantity: 1.00\nProductAssemblyID: 751, StandardCost: 2171.2942, TotalQuantity: 1.00\n```\n\n### SqlEnumProvider\n\nLet's say we need to retrieve number of orders shipped by a certain shipping method since specific date.\n\n```fsharp\n//by convention: first column is Name, second is Value\ntype ShipMethod = SqlEnumProvider\u003c\"\n    SELECT Name, ShipMethodID FROM Purchasing.ShipMethod ORDER BY ShipMethodID\", connectionString\u003e\n\n//Combine with SqlCommandProvider\ndo \n    use cmd = new SqlCommandProvider\u003c\"\n        SELECT COUNT(*) \n        FROM Purchasing.PurchaseOrderHeader \n        WHERE ShipDate \u003e @shippedLaterThan AND ShipMethodID = @shipMethodId\n    \", connectionString, SingleRow = true\u003e(connectionString) \n    //overnight orders shipped since Jan 1, 2008 \n    cmd.Execute( System.DateTime( 2008, 1, 1), ShipMethod.``OVERNIGHT J-FAST``) |\u003e printfn \"%A\"\n```\noutput\n```fsharp\nSome (Some 1085)\n```\n\n### SqlFileProvider\n\n```fsharp\ntype SampleCommand = SqlFile\u003c\"sampleCommand.sql\"\u003e\ntype SampleCommandRelative = SqlFile\u003c\"sampleCommand.sql\", \"MySqlFolder\"\u003e\n\nuse cmd1 = new SqlCommandProvider\u003cSampleCommand.Text, ConnectionStrings.AdventureWorksNamed\u003e()\nuse cmd2 = new SqlCommandProvider\u003cSampleCommandRelative.Text, ConnectionStrings.AdventureWorksNamed\u003e()\n```\n\nMore information can be found in the [documentation](http://fsprojects.github.io/FSharp.Data.SqlClient/).\n\n## Build Status\n\n| Windows | Linux | NuGet |\n|:-------:|:-----:|:-----:|\n|[![Build status (Windows Server 2012, AppVeyor)](https://ci.appveyor.com/api/projects/status/gxou8oe4lt5adxbq)](https://ci.appveyor.com/project/fsgit/fsharp-data-sqlclient)|[![Build Status](https://travis-ci.org/fsprojects/FSharp.Data.SqlClient.svg?branch=master)](https://travis-ci.org/fsprojects/FSharp.Data.SqlClient)|[![NuGet Status](http://img.shields.io/nuget/v/FSharp.Data.SqlClient.svg?style=flat)](https://www.nuget.org/packages/FSharp.Data.SqlClient/)|\n\n### Maintainers\n\n- [@smoothdeveloper](https://github.com/smoothdeveloper)\n\nThe default maintainer account for projects under \"fsprojects\" is [@fsprojectsgit](https://github.com/fsprojectsgit) - F# Community Project Incubation Space (repo management)\n\nThanks Jetbrains for their open source license program and providing their tool.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffsprojects%2Ffsharp.data.sqlclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffsprojects%2Ffsharp.data.sqlclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffsprojects%2Ffsharp.data.sqlclient/lists"}