SQLProvider


SQL Provider Static Parameters

Global parameters

These are the "common" parameters used by all SqlProviders.

All static parameters must be known at compile time, for strings this can be achieved by adding the [<Literal>] attribute if you are not passing it inline.

ConnectionString

This is the connection string commonly used to connect to a database server instance. See the documentation on your desired database type to find out more.

1: 
2: 
3: 
[<Literal>]
let sqliteConnectionString =
    "Data Source=" + __SOURCE_DIRECTORY__ + @"\northwindEF.db;Version=3"

ConnectionStringName

Instead of storing the connection string in the source code / fsx script, you can store values in the App.config file. This is the name of the connectionString key/value pair stored in App.config

1: 
let connexStringName = "MyDatabase"

DatabaseVendor

Select enumeration from Common.DatabaseProviderTypes to specify which database type the provider will be connecting to.

1: 
2: 
[<Literal>]
let dbVendor = Common.DatabaseProviderTypes.SQLITE

ResolutionPath

When using database vendors other than SQL Server, Access and ODBC, a third party driver is required. This parameter should point to an absolute or relative directory where the relevant assemblies are located. See the database vendor specific page for more details.

1: 
2: 
3: 
[<Literal>]
let resolutionPath =
    __SOURCE_DIRECTORY__ + @"..\..\..\files\sqlite"

IndividualsAmount

Number of instances to retrieve when using the individuals feature. Default is 1000.

1: 
let indivAmt = 500

UseOptionTypes

If set to true, all nullable fields will be represented by F# option types. If false, nullable fields will be represented by the default value of the column type - this is important because the provider will return 0 instead of null, which might cause problems in some scenarios.

1: 
2: 
[<Literal>]
let useOptionTypes = true

Platform Considerations

MSSQL

TableNames to filter amount of tables.

Oracle

TableNames to filter amount of tables, and Owner.

Owner (Used by Oracle, MySQL and PostgreSQL)

This has different meanings when running queries against different database vendors

For PostgreSQL, this sets the schema name where the target tables belong to For MySQL, this sets the database name (Or schema name, for MySQL, it's the same thing) For Oracle, this sets the owner of the scheme

SQLite

The additional SQLiteLibrary parameter can be used to specify which SQLite library to load.

PostgreSQL

No extra parameters.

MySQL

No extra parameters.

ODBC

No extra parameters.

Example

It is recommended to use named static parameters in your type provider definition like so

1: 
2: 
3: 
4: 
5: 
6: 
type sql = SqlDataProvider<
            ConnectionString = sqliteConnectionString,
            DatabaseVendor = dbVendor,
            ResolutionPath = resolutionPath,
            UseOptionTypes = useOptionTypes
          >
Multiple items
namespace FSharp

--------------------
namespace Microsoft.FSharp
Multiple items
namespace FSharp.Data

--------------------
namespace Microsoft.FSharp.Data
namespace FSharp.Data.Sql
Multiple items
type LiteralAttribute =
  inherit Attribute
  new : unit -> LiteralAttribute

Full name: Microsoft.FSharp.Core.LiteralAttribute

--------------------
new : unit -> LiteralAttribute
val sqliteConnectionString : string

Full name: Parameters.sqliteConnectionString
val connexStringName : string

Full name: Parameters.connexStringName
val dbVendor : Common.DatabaseProviderTypes

Full name: Parameters.dbVendor
namespace FSharp.Data.Sql.Common
type DatabaseProviderTypes =
  | MSSQLSERVER = 0
  | SQLITE = 1
  | POSTGRESQL = 2
  | MYSQL = 3
  | ORACLE = 4
  | MSACCESS = 5
  | ODBC = 6

Full name: FSharp.Data.Sql.Common.DatabaseProviderTypes
Common.DatabaseProviderTypes.SQLITE: Common.DatabaseProviderTypes = 1
val resolutionPath : string

Full name: Parameters.resolutionPath
val indivAmt : int

Full name: Parameters.indivAmt
val useOptionTypes : bool

Full name: Parameters.useOptionTypes
type sql = obj

Full name: Parameters.sql
type SqlDataProvider

Full name: FSharp.Data.Sql.SqlDataProvider


<summary>Typed representation of a database</summary>
                    <param name='ConnectionString'>The connection string for the SQL database</param>
                    <param name='ConnectionStringName'>The connection string name to select from a configuration file</param>
                    <param name='DatabaseVendor'> The target database vendor</param>
                    <param name='IndividualsAmount'>The amount of sample entities to project into the type system for each SQL entity type. Default 1000.</param>
                    <param name='UseOptionTypes'>If true, F# option types will be used in place of nullable database columns. If false, you will always receive the default value of the column's type even if it is null in the database.</param>
                    <param name='ResolutionPath'>The location to look for dynamically loaded assemblies containing database vendor specific connections and custom types.</param>
                    <param name='Owner'>The owner of the schema for this provider to resolve (Oracle Only)</param>
                    <param name='CaseSensitivityChange'>Should we do ToUpper or ToLower when generating table names?</param>
                    <param name='TableNames'>Comma separated table names list to limit a number of tables in big instances. The names can have '%' sign to handle it as in the 'LIKE' query (Oracle and MSSQL Only)</param>
                    <param name='OdbcQuote'>Odbc quote characters: Quote characters for the table and column names: `alias`, [alias]</param>
                    <param name='SQLiteLibrary'>Use System.Data.SQLite or Mono.Data.SQLite or select automatically (SQLite only)</param>
                    
Fork me on GitHub