FSharp.Data.TypeProviders


The SqlDataConnection Type Provider (FSharp.Data.TypeProviders)

Please see Walkthrough: Accessing a SQL Database by Using Type Providers

NOTE: Use FSharp.Data.TypeProviders instead of Microsoft.FSharp.Data.TypeProviders

Reference

Please see the MSDN Documentation

Example

Please see Walkthrough: Accessing a SQL Database by Using Type Providers

See also below for a micro example use of the type provider:

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
#r "System.Data.Linq.dll"
#r "FSharp.Data.TypeProviders.dll"
open FSharp.Data.TypeProviders

// The database connection string
let [<Literal>] CONN = 
    @"AttachDBFileName='C:\DB\NORTHWND.MDF';Server='(localdb)\MSSQLLocalDB'"

// Connect to the database at compile-time
type SqlData1 = SqlDataConnection<CONN>

// Connect to the database at runtime
let ctxt = SqlData1.GetDataContext()

// Execute a query
let categories = 
    query { for d in ctxt.Categories do
            where (d.CategoryID > 10)
            select (d.CategoryName, d.Description) } 
Multiple items
namespace FSharp

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

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

Full name: Microsoft.FSharp.Core.LiteralAttribute

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

Full name: Sqldata.CONN
type SqlData1

Full name: Sqldata.SqlData1
type SqlDataConnection

Full name: FSharp.Data.TypeProviders.SqlDataConnection


<summary>Provides the types to access a database, using a LINQ-to-SQL mapping</summary><param name='ConnectionString'>The connection string for the database connection. If using Visual Studio, a connection string can be found in database properties in the Server Explorer window.</param><param name='ConnectionStringName'>The name of the connection string for the database connection in the configuration file.</param><param name='LocalSchemaFile'>The local .dbml file for the database schema (default: no local schema file)</param><param name='ForceUpdate'>Require that a direct connection to the database be available at design-time and force the refresh of the local schema file (default: true)</param><param name='Pluralize'>Automatically pluralize or singularize class and member names using English language rules (default: false)</param><param name='Views'>Extract database views (default: true)</param><param name='Functions'>Extract database functions (default: true)</param><param name='ConfigFile'>The name of the configuration file used for connection strings (default: app.config or web.config is used)</param><param name='DataDirectory'>The name of the data directory, used to replace |DataDirectory| in connection strings (default: the project or script directory)</param><param name='ResolutionFolder'>The folder used to resolve relative file paths at compile-time (default: folder containing the project or script)</param><param name='StoredProcedures'>Extract stored procedures (default: true)</param><param name='Timeout'>Timeout value in seconds to use when SqlMetal accesses the database (default: 0, which means infinite)</param><param name='ContextTypeName'>The name of data context class (default: derived from database name)</param><param name='Serializable'>Generate uni-directional serializable classes (default: false, which means no serialization)</param>
val ctxt : obj

Full name: Sqldata.ctxt
val categories : System.Linq.IQueryable<obj * obj>

Full name: Sqldata.categories
val query : Linq.QueryBuilder

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.query
val d : obj
custom operation: where (bool)

Calls Linq.QueryBuilder.Where
custom operation: select ('Result)

Calls Linq.QueryBuilder.Select
Fork me on GitHub