【发布时间】:2017-10-08 13:22:27
【问题描述】:
无论出于何种原因,我都不能在查询表达式中使用“for”构造。我得到的是以下错误。我刚刚选择的代码曾经可以工作--> "错误:只有在计算表达式构建器定义了一个 '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
【问题讨论】:
-
奇怪的是,这发生在一个脚本中,而不是另一个。
标签: for-loop f# query-expressions