0

我能够获得一段代码以在 .fsx 脚本中运行。我从来没有看到它在我要撤回的轨道数据上循环。所以我想我会把它放在一个 .fs 文件中并编译它。我遇到了2个问题。F# IDE 为 let 查询 = 行中的 type 关键字和 let 加下划线。这是我的 oode (下)我在哪里关闭语法?

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
4

1 回答 1

2

这可能有效 - 您不能在函数内部定义类型

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
于 2012-11-20T20:44:31.987 回答