SQLProvider


MySQL Provider

Parameters

ConnectionString

Basic connection string used to connect to MySQL instance; typical connection string parameters apply here. See MySQL Connector/NET Connection Strings Documentation for a complete list of connection string options.

1: 
2: 
[<Literal>]
let connString  = "Server=localhost;Database=HR;User=root;Password=password"

ConnectionStringName

Instead of storing the connection string in the source code, you can store it in the App.config file. This is the name of the connectionString key/value pair stored in App.config (TODO: confirm filename).

1: 
2: 
// found in App.config (TODO: confirm)
let connexStringName = "DefaultConnectionString"

Database Vendor

Use MYSQL from the FSharp.Data.Sql.Common.DatabaseProviderTypes enumeration.

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

Resolution Path

Path to search for assemblies containing database vendor specific connections and custom types. Type the path where Mysql.Data.dll is stored. Both absolute and relative paths are supported.

1: 
2: 
[<Literal>]
let resPath = __SOURCE_DIRECTORY__ + @"/../../../packages/scripts/MySql.Data/lib/net45"

Individuals Amount

Sets the count of records to load for each table. See individuals for further info.

1: 
2: 
[<Literal>]
let indivAmount = 1000

Use Option Types

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.

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

Example

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
type sql = SqlDataProvider<
                dbVendor,
                connString,
                ResolutionPath = resPath,
                IndividualsAmount = indivAmount,
                UseOptionTypes = useOptTypes,
                Owner = "HR"
            >
let ctx = sql.GetDataContext()

let employees = 
    ctx.Hr.Employees 
    |> Seq.map (fun e -> e.ColumnValues |> Seq.toList)
    |> Seq.toList

Caveats / Additional Info

Check General, Static Parameters and Querying documentation.

More to be added.

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 connString : string

Full name: Mysql.connString
val connexStringName : string

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

Full name: Mysql.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.MYSQL: Common.DatabaseProviderTypes = 3
val resPath : string

Full name: Mysql.resPath
val indivAmount : int

Full name: Mysql.indivAmount
val useOptTypes : bool

Full name: Mysql.useOptTypes
type sql = obj

Full name: Mysql.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>
                    
val ctx : obj

Full name: Mysql.ctx
val employees : obj list list

Full name: Mysql.employees
Multiple items
module Seq

from FSharp.Data.Sql

--------------------
module Seq

from Microsoft.FSharp.Collections
val map : mapping:('T -> 'U) -> source:seq<'T> -> seq<'U>

Full name: Microsoft.FSharp.Collections.Seq.map
val e : obj
val toList : source:seq<'T> -> 'T list

Full name: Microsoft.FSharp.Collections.Seq.toList
Fork me on GitHub