Skip to content

Commit bdcee98

Browse files
Merge branch 'master' into feature/temp-tvp-types
# Conflicts: # build.sh # src/SqlClient.Tests/app.config # src/SqlClient.Tests/packages.config # src/SqlClient/ISqlCommand.fs # src/SqlClient/packages.config
2 parents 85e1839 + c985167 commit bdcee98

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3287
-3721
lines changed

.gitignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,13 @@ pip-log.txt
226226
vagrantfile
227227
*.userprefs
228228
/sqlclientmonosample
229-
.fake/
229+
.fake/
230+
/_NCrunch_SqlProgrammabilityProvider/StoredText
231+
.idea
232+
paket-files
233+
paket.exe
234+
Paket.Restore.targets
235+
.paket
236+
/docs/output
237+
docs/output/**/*.*
238+
*.orig

.nuget/NuGet.Config

Lines changed: 0 additions & 6 deletions
This file was deleted.

.nuget/NuGet.exe

-4.07 MB
Binary file not shown.

.nuget/NuGet.targets

Lines changed: 0 additions & 136 deletions
This file was deleted.

.paket/paket.bootstrapper.exe

62.8 KB
Binary file not shown.

.paket/paket.targets

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<PropertyGroup>
5+
<!-- Enable the restore command to run before builds -->
6+
<RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>
7+
<PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath>
8+
<PaketRootPath>$(MSBuildThisFileDirectory)..\</PaketRootPath>
9+
<PaketLockFilePath>$(PaketRootPath)paket.lock</PaketLockFilePath>
10+
<PaketRestoreCacheFile>$(PaketRootPath)paket-files\paket.restore.cached</PaketRestoreCacheFile>
11+
<MonoPath Condition="'$(MonoPath)' == '' And Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
12+
<MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
13+
</PropertyGroup>
14+
15+
<PropertyGroup>
16+
<!-- Paket command -->
17+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe')">$(PaketRootPath)paket.exe</PaketExePath>
18+
<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath>
19+
<PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
20+
<PaketCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand>
21+
</PropertyGroup>
22+
23+
<Choose> <!-- MyProject.fsproj.paket.references has the highest precedence -->
24+
<When Condition="Exists('$(MSBuildProjectFullPath).paket.references')">
25+
<PropertyGroup>
26+
<PaketReferences>$(MSBuildProjectFullPath).paket.references</PaketReferences>
27+
</PropertyGroup>
28+
</When> <!-- MyProject.paket.references -->
29+
<When Condition="Exists('$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references')">
30+
<PropertyGroup>
31+
<PaketReferences>$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references</PaketReferences>
32+
</PropertyGroup>
33+
</When> <!-- paket.references -->
34+
<When Condition="Exists('$(MSBuildProjectDirectory)\paket.references')">
35+
<PropertyGroup>
36+
<PaketReferences>$(MSBuildProjectDirectory)\paket.references</PaketReferences>
37+
</PropertyGroup>
38+
</When> <!-- Set to empty if a reference file isn't found matching one of the 3 format options -->
39+
<Otherwise>
40+
<PropertyGroup>
41+
<PaketReferences></PaketReferences>
42+
</PropertyGroup>
43+
</Otherwise>
44+
</Choose>
45+
46+
<PropertyGroup>
47+
<!-- Commands -->
48+
<RestoreCommand>$(PaketCommand) restore --references-file "$(PaketReferences)"</RestoreCommand>
49+
<!-- We need to ensure packages are restored prior to assembly resolve -->
50+
<BuildDependsOn Condition="$(RestorePackages) == 'true'">RestorePackages; $(BuildDependsOn);</BuildDependsOn>
51+
</PropertyGroup>
52+
<Target Name="RestorePackages">
53+
<PropertyGroup>
54+
<PaketRestoreRequired>true</PaketRestoreRequired>
55+
</PropertyGroup>
56+
57+
<PropertyGroup Condition="Exists('$(PaketRestoreCacheFile)') ">
58+
<PaketRestoreCachedHash>$([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))</PaketRestoreCachedHash>
59+
<PaketRestoreLockFileHash>$([System.IO.File]::ReadAllText('$(PaketLockFilePath)'))</PaketRestoreLockFileHash>
60+
<PaketRestoreRequired>true</PaketRestoreRequired>
61+
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '$(PaketRestoreCachedHash)' ">false</PaketRestoreRequired>
62+
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired>
63+
</PropertyGroup>
64+
65+
<Exec Command="$(RestoreCommand)"
66+
IgnoreStandardErrorWarningFormat="true"
67+
WorkingDirectory="$(PaketRootPath)"
68+
ContinueOnError="false"
69+
Condition=" '$(PaketRestoreRequired)' == 'true' AND Exists('$(PaketReferences)') AND '$(PaketReferences)' != '' "
70+
/>
71+
</Target>
72+
</Project>

README.md

Lines changed: 91 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,105 @@
1-
SqlClient providers [![NuGet Status](http://img.shields.io/nuget/v/FSharp.Data.SqlClient.svg?style=flat)](https://www.nuget.org/packages/FSharp.Data.SqlClient/)
2-
==============================
1+
# SqlClient providers
32

4-
SqlCommandProvider provides statically typed access to input parameters and result set of T-SQL command in idiomatic F# way.
3+
## SqlCommandProvider
54

6-
SqlProgrammabilityProvider exposes Stored Procedures, User-Defined Types and User-Defined Functions in F# code.
5+
Provides statically typed access to input parameters and result set of T-SQL command in idiomatic F# way.
76

8-
More information can be found in the [documentation](http://fsprojects.github.io/FSharp.Data.SqlClient/).
7+
```fsharp
8+
open FSharp.Data
9+
10+
[<Literal>]
11+
let connectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True"
12+
13+
// The query below retrieves top 3 sales representatives from North American region with YTD sales of more than one million.
14+
15+
do
16+
use cmd = new SqlCommandProvider<"
17+
SELECT TOP(@topN) FirstName, LastName, SalesYTD
18+
FROM Sales.vSalesPerson
19+
WHERE CountryRegionName = @regionName AND SalesYTD > @salesMoreThan
20+
ORDER BY SalesYTD
21+
" , connectionString>(connectionString)
22+
23+
cmd.Execute(topN = 3L, regionName = "United States", salesMoreThan = 1000000M) |> printfn "%A"
24+
```
25+
output
26+
```fsharp
27+
seq
28+
[("Pamela", "Ansman-Wolfe", 1352577.1325M);
29+
("David", "Campbell", 1573012.9383M);
30+
("Tete", "Mensa-Annan", 1576562.1966M)]
31+
```
32+
33+
## SqlProgrammabilityProvider
34+
35+
Exposes Tables, Stored Procedures, User-Defined Types and User-Defined Functions in F# code.
36+
37+
```fsharp
38+
type AdventureWorks = SqlProgrammabilityProvider<connectionString>
39+
do
40+
use cmd = new AdventureWorks.dbo.uspGetWhereUsedProductID(connectionString)
41+
for x in cmd.Execute( StartProductID = 1, CheckDate = System.DateTime(2013,1,1)) do
42+
//check for nulls
43+
match x.ProductAssemblyID, x.StandardCost, x.TotalQuantity with
44+
| Some prodAsmId, Some cost, Some qty ->
45+
printfn "ProductAssemblyID: %i, StandardCost: %M, TotalQuantity: %M" prodAsmId cost qty
46+
| _ -> ()
47+
```
48+
output
49+
```fsharp
50+
ProductAssemblyID: 749, StandardCost: 2171.2942, TotalQuantity: 1.00
51+
ProductAssemblyID: 750, StandardCost: 2171.2942, TotalQuantity: 1.00
52+
ProductAssemblyID: 751, StandardCost: 2171.2942, TotalQuantity: 1.00
53+
```
954

10-
Build Status
11-
-----------
55+
## SqlEnumProvider
56+
57+
Let's say we need to retrieve number of orders shipped by a certain shipping method since specific date.
58+
59+
```fsharp
60+
//by convention: first column is Name, second is Value
61+
type ShipMethod = SqlEnumProvider<"
62+
SELECT Name, ShipMethodID FROM Purchasing.ShipMethod ORDER BY ShipMethodID", connectionString>
63+
64+
//Combine with SqlCommandProvider
65+
do
66+
use cmd = new SqlCommandProvider<"
67+
SELECT COUNT(*)
68+
FROM Purchasing.PurchaseOrderHeader
69+
WHERE ShipDate > @shippedLaterThan AND ShipMethodID = @shipMethodId
70+
", connectionString, SingleRow = true>(connectionString)
71+
//overnight orders shipped since Jan 1, 2008
72+
cmd.Execute( System.DateTime( 2008, 1, 1), ShipMethod.``OVERNIGHT J-FAST``) |> printfn "%A"
73+
```
74+
output
75+
```fsharp
76+
Some (Some 1085)
77+
```
78+
79+
## SqlFileProvider
80+
81+
```fsharp
82+
type SampleCommand = SqlFile<"sampleCommand.sql">
83+
type SampleCommandRelative = SqlFile<"sampleCommand.sql", "MySqlFolder">
84+
85+
use cmd1 = new SqlCommandProvider<SampleCommand.Text, ConnectionStrings.AdventureWorksNamed>()
86+
use cmd2 = new SqlCommandProvider<SampleCommandRelative.Text, ConnectionStrings.AdventureWorksNamed>()
87+
```
88+
89+
More information can be found in the [documentation](http://fsprojects.github.io/FSharp.Data.SqlClient/).
1290

13-
[![Build status (Windows Server 2012, AppVeyor)](https://ci.appveyor.com/api/projects/status/gxou8oe4lt5adxbq)](https://ci.appveyor.com/project/fsgit/fsharp-data-sqlclient)
91+
## Build Status
1492

93+
| Windows | Linux | NuGet |
94+
|:-------:|:-----:|:-----:|
95+
|[![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/)|
1596

16-
### Maintainer(s)
97+
### Maintainers
1798

1899
- [@dmitry-a-morozov](https://github.com/dmitry-a-morozov)
19100
- [@dsevastianov](https://github.com/dsevastianov)
20101
- [@vasily-kirichenko](https://github.com/vasily-kirichenko)
102+
- [@smoothdeveloper](https://github.com/smoothdeveloper)
21103

22104
The default maintainer account for projects under "fsprojects" is [@fsprojectsgit](https://github.com/fsprojectsgit) - F# Community Project Incubation Space (repo management)
23105

Samples.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 2013
44
VisualStudioVersion = 12.0.30110.0
55
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{3F96B803-B577-49EF-80BE-9185D114135F}"
7+
ProjectSection(SolutionItems) = preProject
8+
paket.dependencies = paket.dependencies
9+
EndProjectSection
10+
EndProject
611
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApi", "src\SqlClient.Samples\WebApi\WebApi.csproj", "{EB1F8003-352C-448B-81AC-9823BEB1B325}"
712
EndProject
813
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "WebApi.Controllers", "src\SqlClient.Samples\WebApi.Controllers\WebApi.Controllers.fsproj", "{92308B2E-43B4-4C4C-9446-87D02C4E455D}"

SqlClient.sln

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
44
VisualStudioVersion = 14.0.24720.0
55
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{FD7933BD-2A90-49EB-A4B2-95F9D3076BBD}"
7+
ProjectSection(SolutionItems) = preProject
8+
paket.dependencies = paket.dependencies
9+
EndProjectSection
10+
EndProject
611
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{7ECDF2A7-A71C-43B5-AFF2-64468098B7B6}"
712
ProjectSection(SolutionItems) = preProject
8-
.nuget\NuGet.Config = .nuget\NuGet.Config
9-
.nuget\NuGet.exe = .nuget\NuGet.exe
10-
.nuget\NuGet.targets = .nuget\NuGet.targets
1113
nuget\SqlClient.nuspec = nuget\SqlClient.nuspec
1214
EndProjectSection
1315
EndProject

Tests.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
44
VisualStudioVersion = 14.0.25420.1
55
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{E35ED000-5A6C-49E1-82CF-55CB8C16C2AB}"
7+
ProjectSection(SolutionItems) = preProject
8+
paket.dependencies = paket.dependencies
9+
EndProjectSection
10+
EndProject
611
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SqlClient.Tests", "src\SqlClient.Tests\SqlClient.Tests.fsproj", "{624C31FF-2003-4334-B02E-AD5A79FE9ED8}"
712
EndProject
813
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SqlClient.Tests.NET40", "src\SqlClient.Tests\SqlClient.Tests.NET40\SqlClient.Tests.NET40.fsproj", "{DE2EC181-0452-415D-82C3-1D43168D4FF1}"

0 commit comments

Comments
 (0)