fsprojects / SQLProvider

A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides.
https://fsprojects.github.io/SQLProvider
Other
580 stars 146 forks source link

Suggestion - infer resolution path for script scenario .fsx (MacOs) ? #764

Open jkone27 opened 2 years ago

jkone27 commented 2 years ago

Describe the bug Would be nice if resolution path would be inferred by .nuget directory of .fsx script automatically... also seems #r "nuget: System.Data.SqlClient" is required else the type throws an exception...

To Reproduce use provider from .fsx script and try reference ngpqslq.dll from current directory

#r "nuget: SQLProvider"
#r "nuget: System.Data.SqlClient"
#r "nuget: Npgsql"

open FSharp.Data.Sql
open System
open Npgsql

//docker run --name posttest -d -p 5432:5432 -e POSTGRES_PASSWORD=password postgres:alpine

let [<Literal>] dbVendor = 
    Common.DatabaseProviderTypes.POSTGRESQL

let [<Literal>] connString = 
    "Host=127.0.0.1;Database=postgres;Username=postgres;Password=password;Port=5432"

let [<Literal>] resPath = __SOURCE_DIRECTORY__

// add npgsql.dll locally
type sql = SqlDataProvider<DatabaseVendor=dbVendor, ConnectionString=connString, ResolutionPath=resPath>

Expected behavior Would be nice not to need the resolution path when using the type provider from scripts using

r "nuget : SQLProvider"

Desktop (please complete the following information):

Thorium commented 2 years ago

This is a great idea, but how do we know the path of that DLL? With '#r' the FSI loads the SQLProvider then from nuget cache, but SQLProvider loads Npgsql via reflection, so we'd need to know the path and thus e.g. which version we are loading.

It seems to me that FSI creates some kind of temporary project in some location %home%\.packagemanagement\nuget\Projects\(guid)