类型提供程序问题 - 主要入口点 - 语法

时间:2012-11-20 20:24:40

标签: .net f# type-providers f#-3.0

我能够在.fsx脚本中运行一段代码。我从来没有看到它在我正在拉回的轨道数据上循环。所以我想我会把它放在.fs文件中并编译它。我遇到了两个问题。 F#IDE在let query =行中强调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

1 个答案:

答案 0 :(得分: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