Reputation: 71101
I was able to get a piece of code to run in an .fsx script. I never did see it loop over the track data I'm pulling back. So I thought I would put it in an .fs file and compile it. I'm running into 2 issues. F# IDE underlines the type keyword and the let in the let query = line. Here is my oode (below) Where am I off on the syntax?
open System
open System.Data
open System.Data.Linq
open Microsoft.FSharp.Data.TypeProviders
open Microsoft.FSharp.Linq
[<EntryPoint>]
let main argv =
type dbSchema = SqlDataConnection<"Data Source=SQLDEV;Initial Catalog=CDDB;Integrated Security=SSPI;">
let db = dbSchema.GetDataContext()
// Enable the logging of database activity to the console.
db.DataContext.Log <- System.Console.Out
let query1 =
query {
for row in db.SoundRecording do
select row
take 50
}
query1 |> Seq.iter (fun row -> printfn "%s - %s" row.DisplayArtist row.DisplayTitle)
0 // return an integer exit code
Upvotes: 0
Views: 160
Reputation: 25516
This may work - you can't have type definitions inside functions
open System
open System.Data
open System.Data.Linq
open Microsoft.FSharp.Data.TypeProviders
open Microsoft.FSharp.Linq
type dbSchema = SqlDataConnection<"Data Source=SQLDEV;Initial Catalog=CDDB;Integrated Security=SSPI;">
[<EntryPoint>]
let main argv =
let db = dbSchema.GetDataContext()
// Enable the logging of database activity to the console.
db.DataContext.Log <- System.Console.Out
let query1 =
query {
for row in db.SoundRecording do
select row
take 50
}
query1 |> Seq.iter (fun row -> printfn "%s - %s" row.DisplayArtist row.DisplayTitle)
0 // return an integer exit code
Upvotes: 2