No 'HasValue' property exists for a nullable int for an ODataService provider

I am trying to use a provider like ODataService with Netflix. This works great:

type internal NetflixData = ODataService<"http://odata.netflix.com/Catalog/"> let internal NetflixContext = NetflixData.GetDataContext() let godzillamovies = query { for t in NetflixContext.Titles do where (t.Name.Contains "Godzilla") select (t.Name, t.ReleaseYear) } |> Seq.toList 

but returns all episodes of the Godzilla TV show, with no release dates (boo). So, I am updating my request to:

 let godzillamovies = query { for t in NetflixContext.Titles do where (t.Name.Contains "Godzilla" && t.ReleaseYear.HasValue) select (t.Name, t.ReleaseYear.Value) } |> Seq.toList 

And I came across the following error:

 <?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?> <error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"> <code></code> <message xml:lang=\"en-US\">No property 'HasValue' exists in type 'System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' at position 45.</message> </error> 

Uh, HasValue does not exist for null ints? Because ... when?

+6
source share
1 answer
 #r "FSharp.Data.TypeProviders" #r "System.Data.Services.Client" open Microsoft.FSharp.Data.TypeProviders open Microsoft.FSharp.Linq.NullableOperators type internal NetflixData = ODataService<"http://odata.netflix.com/Catalog/"> let internal NetflixContext = NetflixData.GetDataContext() NetflixContext.DataContext.SendingRequest.Add(fun e -> printfn "%A" e.Request.RequestUri) // http://odata.netflix.com/Catalog/Titles()?$filter=substringof('Godzilla',Name) and (ReleaseYear ne null)&$select=Name,ReleaseYear let godzillamovies = query { for t in NetflixContext.Titles do where (t.Name.Contains "Godzilla") where (t.ReleaseYear ?<>? System.Nullable()) select (t.Name, t.ReleaseYear) } |> Seq.toList 
+6
source

All Articles