现在的位置: 首页 > 综合 > 正文

用 OData Service 访问 U.S. Consumer Price Index

2014年07月06日 ⁄ 综合 ⁄ 共 1459字 ⁄ 字号 评论关闭

用 OData Service 访问 U.S. Consumer Price Index

// 编译命令
//"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\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  TypeProviderCPI.fsx

#if INTERACTIVE
#r @"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.Services.Client.dll";;
#endif
open System.Data.Services.Client;;
#if INTERACTIVE
#r @"E:\Projects\F#3\FSharp.Data.TypeProviders.dll"
#endif
open Microsoft.FSharp.Data.TypeProviders;;

open System.Net;;
open System;;

[<Generate>]
type CPI = Microsoft.FSharp.Data.TypeProviders.ODataService<"https://api.datamarket.azure.com/MetricMash/USConsumerPriceIndex/">

let MetricMash ()=
    let db = CPI.GetDataContext()
    db.Credentials <- NetworkCredential ("MSN帐号","主帐户密钥")

    let q = query {
        for c in db.AllUrbanChainedConsumerPriceIndex do
        where (c.DateValue < new System.DateTime(2010, 1, 1))
        where (c.DateValue > new System.DateTime(2008, 12, 30))
        select c
    }

    q |> Seq.iter ( fun n -> printfn "%A- %A" n.DateValue n.Index)

MetricMash()

【上篇】
【下篇】

抱歉!评论已关闭.