F#内部联接替代查询不起作用(来自Expert F#4.0的示例)

时间:2017-03-16 14:18:29

标签: f#

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

0 个答案:

没有答案