用 OData Service 访问云数据
#if INTERACTIVE
#r @"E:\Projects\F#3\FSharp.Data.TypeProviders.dll";;
#endif
open Microsoft.FSharp.Data.TypeProviders;;
#if INTERACTIVE
#r @"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.Services.Client.dll";;
#endif
open System.Data.Services.Client;;
open System.Net
[<Generate>]
type TO = ODataService< ServiceUri = @"https://api.datamarket.azure.com/Uk.Gov/TravelAdvisoryService/" >
let typeProviderODataSample() =
let travelInfo = TO.GetDataContext()
//To sign up for a Windows Azure Marketplace account @ https://datamarket.azure.com/account/info
do travelInfo.Credentials <- new NetworkCredential ("MSN帐号","主帐户密钥")
let q = query {
for s in travelInfo.BritishEmbassiesAndHighCommissions do
select s
take 3
}
q |> Seq.iter (fun n -> printfn "%s\n" n.Address)
typeProviderODataSample()
1、首先要求一个 MSN 的帐号;
2、用这个帐号去登录:https://datamarket.azure.com/account/info ;
3、会产生一个数据集市的帐号,记下其主帐户密码;
4、进入数据;
5、找到 UK Foreign and Commonwealth Office Travel Advisory Service,大概在第二页;
6、进入,并注册。
用 OData Service 访问云数据
#if INTERACTIVE
#r @"E:\Projects\F#3\FSharp.Data.TypeProviders.dll";;
#endif
open Microsoft.FSharp.Data.TypeProviders;;
#if INTERACTIVE
#r @"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.Services.Client.dll";;
#endif
open System.Data.Services.Client;;
open System.Net
[<Generate>]
type TO = ODataService< ServiceUri = @"https://api.datamarket.azure.com/Uk.Gov/TravelAdvisoryService/" >
let typeProviderODataSample() =
let travelInfo = TO.GetDataContext()
//To sign up for a Windows Azure Marketplace account @ https://datamarket.azure.com/account/info
do travelInfo.Credentials <- new NetworkCredential ("MSN帐号","主帐户密钥")
let q = query {
for s in travelInfo.BritishEmbassiesAndHighCommissions do
select s
take 3
}
q |> Seq.iter (fun n -> printfn "%s\n" n.Address)
typeProviderODataSample()
1、首先要求一个 MSN 的帐号;
2、用这个帐号去登录:https://datamarket.azure.com/account/info ;
3、会产生一个数据集市的帐号,记下其主帐户密码;
4、进入数据;
5、找到 UK Foreign and Commonwealth Office Travel Advisory Service,大概在第二页;
6、进入,并注册。
编译命令:
"C:\Program Files\Microsoft SDKs\F#\3.0\Framework\v4.0\fsc.exe" --optimize- --tailcalls- --platform:x86 -r:"C:\Program Files\Reference Assemblies\Microsoft\FSharp\3.0\Runtime\v4.0\FSharp.Core.dll" -r:"E:\Projects\F#3\FSharp.Data.TypeProviders.dll" -r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Profile\Client\mscorlib.dll" -r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Profile\Client\System.Core.dll" -r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Profile\Client\System.Data.Services.Client.dll" -r:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Profile\Client\System.dll" --noframework XXXXXXXX.fsx
移植后需要:FSharp.Core.dll