我有以下代码,旨在列出在 Freebase 上列出的证券交易所网站:
#if INTERACTIVE
#r @"C:\Users\kit\Documents\Visual Studio 11\Projects\Demo\packages\FSharpx.TypeProviders.1.7.4\lib\40\FSharpx.TypeProviders.dll"
#r @"C:\Users\kit\Documents\Visual Studio 11\Projects\Demo\packages\FSharpx.TypeProviders.Freebase.1.7.4\lib\40\FSharpx.TypeProviders.Freebase.dll"
#r @"C:\Users\kit\Documents\Visual Studio 11\Projects\Demo\packages\FSharpx.TypeProviders.Freebase.1.7.4\lib\40\FSharpx.TypeProviders.Freebase.DesignTime.dll"
#endif
let GetExchanges() =
let dc = FreebaseData.GetDataContext()
dc.DataContext.SendingRequest.Add(fun e -> printfn "url: %s" e.RequestUri.AbsoluteUri)
dc.``Products and Services``.Business.``Stock exchanges``
|> Seq.truncate 10
|> Seq.iter (fun exchange -> printfn "Exchange: %s" exchange.Name
exchange.``Official website``
|> Seq.iter (fun site -> printfn "%s" site.Name))
如果没有最后两行(即仅列出 Exchange 名称),则代码可以正常工作。有了这些行,我得到了 400(错误请求)。
该行生成的 URL 是这样的:
...如果我浏览到它,我会从 Freebase 得到这个:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "badRequest",
"message": "Can't reverse /common/topic/official_website as it expects /type/uri, not an object"
}
],
"code": 400,
"message": "Can't reverse /common/topic/official_website as it expects /type/uri, not an object"
}
}
Am I using the correct approach to accessing linked entities? If so, is this a bug in the Type Provider? I get similar errors accessing other linked entities.