用 ODataService 访问 LexisNexis

来源:互联网 发布:topsview监控软件 编辑:程序博客网 时间:2024/05/22 06:27
用 ODataService 访问 LexisNexis

// 编译命令
//"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  TypeProviderLegalCommunities.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;;

[<Generate>]
type Legal = ODataService<"https://api.datamarket.azure.com/LexisNexis/LegalCommunities/">

let LexisNexis() = 
    //let db = Legal.GetDataContext()
    //  下面的写法也可以
    let db = new Legal.ServiceTypes.LexisNexisLegalCommunitiesContainer()
    db.Credentials <- NetworkCredential ("MSN帐号","主帐户密钥")

    let q = query {
        for c in db.CommunityContent do 
        where ( c.DatePublished > System.DateTime(2011,1,1))
        select c
        take 3
    }

    q |> Seq.iter (fun n -> printfn "%A - %A" n.Author n.Title)

LexisNexis()