Last active
March 3, 2022 00:29
-
-
Save andrzejsliwa/ee12ae9aca0798b99ea29a8e77b4e5d9 to your computer and use it in GitHub Desktop.
Example of proper referencing of FSharp.Data.Npqsql to be able use it from FSI (in project running on dotnetcore)
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
module Database | |
open FSharp.Data | |
open FSharp.Data.Npgsql | |
[<Literal>] | |
let example = "Host=localhost;Username=postgres;Database=example;Port=5432" | |
type Example = NpgsqlConnection<example> | |
let printEmailsAndPhones() = | |
use cmd = Example.CreateCommand<"SELECT email, phone FROM users"> (example) | |
for x in cmd.Execute() do | |
printfn "email : %s, phone: %s" x.email x.phone.Value |
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
#I "/Users/yourusername/.nuget/packages/fsharp.data.npgsql/0.1.44-beta/typeproviders/fsharp41/netcoreapp2.0" | |
#r "FSharp.Core.dll" | |
#r "Microsoft.Extensions.FileProviders.Physical.dll" | |
#r "FSharp.Data.Npgsql.DesignTime.dll" | |
#r "Npgsql.dll" | |
#I "/Users/yourusername/.nuget/packages/fsharp.data.npgsql/0.1.44-beta/lib/netstandard2.0/" | |
#r "FSharp.Data.Npgsql.dll" | |
#load "Database.fs" | |
open Database | |
printEmailsAndPhones() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment