Created
March 14, 2020 08:41
-
-
Save teyc/6cfd974277035b81aee037d12aff12a8 to your computer and use it in GitHub Desktop.
F# SQL provider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>netcoreapp3.1</TargetFramework> | |
</PropertyGroup> | |
<ItemGroup> | |
<Compile Include="Program.fs" /> | |
</ItemGroup> | |
<ItemGroup> | |
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.0" /> | |
</ItemGroup> | |
<Import Project=".paket\Paket.Restore.targets" /> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source https://api.nuget.org/v3/index.json | |
storage: none | |
framework: netcore3.1, netstandard2.0, netstandard2.1 | |
nuget Npgsql | |
nuget SQLProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open FSharp.Data.Sql | |
type DB = SqlDataProvider< | |
Common.DatabaseProviderTypes.POSTGRESQL, | |
"Host=localhost;Port=5432;User ID=postgres;Database=Chui"> | |
let db = DB.GetDataContext() | |
let allCustomers = | |
query { | |
for customer in db.Public.Customers do | |
where (customer.Firstname.Length > 3) | |
select customer | |
} | |
[<EntryPoint>] | |
let main argv = | |
for customer in allCustomers do | |
printfn "%A" customer.Firstname | |
0 // return an integer exit code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment