3 people like it.

Querying NuGet via OData TypeProvider

Querying NuGet package manager via OData TypeProvider

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
#if INTERACTIVE
#r "FSharp.Data.TypeProviders"
#r "System.Data.Services.Client"
#else
module PackageManager
#endif

type Nuget = Microsoft.FSharp.Data.TypeProviders.ODataService<"https://nuget.org/api/v2">
let NugetConnection = Nuget.GetDataContext()
let fetchNugetInfo id version = 
    query { for package in NugetConnection.Packages do
            where (package.Id = id && package.Version = version)
            select package.Title
    }
//fetchNugetInfo "EntityFramework" "6.0.0.0" |> Seq.iter (Console.WriteLine)
type Nuget =
  static member GetDataContext : unit -> V2FeedContext + 1 overload
  nested type ServiceTypes

Full name: Script.Nuget


<summary>Provides the types to access an OData service</summary><param name="ServiceUri">The Uri for the OData service</param><param name='LocalSchemaFile'>The local .csdl file for the service schema</param><param name='ForceUpdate'>Require that a direct connection to the service be available at design-time and force the refresh of the local schema file (default: true)</param><param name='ResolutionFolder'>The folder used to resolve relative file paths at compile-time (default: folder containing the project or script)</param><param name='DataServiceCollection'>Generate collections derived from DataServiceCollection (default: false)</param>
namespace Microsoft
namespace Microsoft.FSharp
namespace Microsoft.FSharp.Data
namespace Microsoft.FSharp.Data.TypeProviders
type ODataService

Full name: Microsoft.FSharp.Data.TypeProviders.ODataService


<summary>Provides the types to access an OData service</summary><param name="ServiceUri">The Uri for the OData service</param><param name='LocalSchemaFile'>The local .csdl file for the service schema</param><param name='ForceUpdate'>Require that a direct connection to the service be available at design-time and force the refresh of the local schema file (default: true)</param><param name='ResolutionFolder'>The folder used to resolve relative file paths at compile-time (default: folder containing the project or script)</param><param name='DataServiceCollection'>Generate collections derived from DataServiceCollection (default: false)</param>
val NugetConnection : Nuget.ServiceTypes.SimpleDataContextTypes.V2FeedContext

Full name: Script.NugetConnection
Nuget.GetDataContext() : Nuget.ServiceTypes.SimpleDataContextTypes.V2FeedContext


Get a simplified data context for this OData Service. By default, no credentials are set

Nuget.GetDataContext(uri: System.Uri) : Nuget.ServiceTypes.SimpleDataContextTypes.V2FeedContext


Get a simplified data context for this OData Service. By default, no credentials are set
val fetchNugetInfo : id:string -> version:string -> System.Linq.IQueryable<string>

Full name: Script.fetchNugetInfo
val id : string
val version : string
val query : Linq.QueryBuilder

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.query
val package : Nuget.ServiceTypes.V2FeedPackage
property Nuget.ServiceTypes.SimpleDataContextTypes.V2FeedContext.Packages: System.Data.Services.Client.DataServiceQuery<Nuget.ServiceTypes.V2FeedPackage>


Gets the 'Packages' entities from the OData Service. This property may be used as the source in a query expression.
custom operation: where (bool)

Calls Linq.QueryBuilder.Where
property Nuget.ServiceTypes.V2FeedPackage.Id: string
property Nuget.ServiceTypes.V2FeedPackage.Version: string
custom operation: select ('Result)

Calls Linq.QueryBuilder.Select
property Nuget.ServiceTypes.V2FeedPackage.Title: string
Next Version Raw view Test code New version

More information

Link:http://fssnip.net/pb
Posted:9 years ago
Author:Tuomas Hietanen
Tags: nuget , odata , type provider , typeprovider