open System
open FSharp.Linq
open FSharp.Data.TypeProviders
type NorthwindDb =
SqlDataConnection<"Data Source=localhost\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=SSPI;">
let db = NorthwindDb.GetDataContext()
db.DataContext.Log <- System.Console.Out
我正在关注查询专家F#4.0第13章。根据这本书,内部联接查询如下:
let innerJoinQuery =
query {
for c in db.Categories do
join p in db.Products on (c.CategoryID =? p.CategoryID)
select (p.ProductName, c.CategoryName)
}
|> Seq.toList
可以替换为
let innerJoinAlternative =
query {
for p in db.Products do
select (p.ProductName, p.Category.CategoryName)
}
|> Seq.toList
我收到以下错误:
error FS0039: The field, constructor or member 'Category' is not defined
注意:Northwind数据库架构为here