OData Type Provider to StackOverflow

References and type definition to open StackOverflow API over OData

Copy Source
Copy Link
Tools:
 1: #r "System.Data.Services.Client"
 2: #r "FSharp.Data.TypeProviders"
 3: 
 4: open Microsoft.FSharp.Data.TypeProviders
 5: 
 6: type stackOverflowData = 
 7:     ODataService<"http://data.stackexchange.com/stackoverflow/atom">
 8: let context = stackOverflowData.GetDataContext()
 9: 
10: query { 
11:     for post in context.Posts do
12:     where (post.Tags.Contains "<f#>")
13:     sortByDescending post.CreationDate.Value
14:     take 10
15:     select post
16: }
17: |> Seq.map (fun post -> sprintf "%O %O %s" post.CreationDate post.AnswerCount post.Title)
18: |> Seq.toArray
namespace Microsoft
namespace Microsoft.FSharp
module Seq

from Microsoft.FSharp.Collections
val map : ('T -> 'U) -> seq<'T> -> seq<'U>

Full name: Microsoft.FSharp.Collections.Seq.map
val sprintf : Printf.StringFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.sprintf
val toArray : seq<'T> -> 'T array

Full name: Microsoft.FSharp.Collections.Seq.toArray

More information

Link: http://fssnip.net/f0
Posted: 1 years ago
Author: Phillip Trelford (website)
Tags: Type Providers, StackOverflow