無論出於何種原因,我無法在查詢表達式中使用「for」構造。我得到的是以下錯誤。該代碼我正是我拿起那個曾經工作 - > 「錯誤:如果計算表達式生成器定義在‘For’方法僅可用於這種控制結構」F#查詢表達式:不能使用「for」!
#r "System.Data.Linq.dll"
#r "FSharp.Data.TypeProviders.dll"
open FSharp.Linq
open FSharp.Data.TypeProviders
[<Literal>]
let connectionString' = @"
data source = ...;
initial catalog = NORTHWND;
Integrated Security = SSPI"
type NorthwndDb =
SqlDataConnection<connectionString', Pluralize = true>
let db' = NorthwndDb.GetDataContext()
let curstomerSortedByCountry =
query { for c in db'.Customers do
sortBy c.Country
select (c.Country, c.CompanyName) }
|> Seq.cache
奇怪的是,這發生在一個腳本中,而不是在另一個腳本中。 –