Reputation: 241
I'm enjoying FSharp.Data.Sql for tests. However I have two problems. As per the sample:
type sql =
SqlDataProvider<
dbVendor,
connString,
IndividualsAmount = indivAmount,
UseOptionTypes = useOptTypes>
a) the compiler keeps resolving the type every time there are changes in the code, making intelisense a bit too slow and also requiring permanent Internet connectivity.
b) having the host, user, and password in code might be convenient for tests and learning but that should never go into production code, ideally those would be environmental varaibles, but FSharp data expects literals.
Is it possible to freeze the type so that at least it is only resolved once and then provide the connection string in runtime?
Upvotes: 2
Views: 56
Reputation: 6324
For your first question, I believe SQLDataProvider
is an erasing type provider, so you won't be able to do this. For other type providers it's sometimes possible to generate a dll and refer to that.
Regarding the database performance it's possible to tune it, but that will depend on the underlying driver, for example for Postgres.
For the second question, you can specify the connection string in the app.config
file.
There are other ways to access the DB, for example Dapper
or EF Core
.
Upvotes: 1