GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ServiceStackVS/fsharp.md at master · wickdninja/ServiceStackVS

Expand file tree

/

fsharp.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
63 lines (39 loc) · 3.27 KB
/

fsharp.md

Copy path

File metadata and controls

63 lines (39 loc) · 3.27 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

ServiceStackVS F#

F# VS.NET ServiceStack Templates

New in ServiceStackVS are a number of different F# Project Templates:

F# templates

These F# templates follow the same recommended multi-project layout used in the C# templates. In addition, there's also a community created F# ServiceStack extension for ServiceStack (V3 and V4) projects containing different single project configurations.

F# ASP.NET with Freebase API Demo

The example below shows how we can use one of the templates to easily create a Service that serves data from Freebase API, showing the elegance of F#'s' concise, readable code working with ServiceStack's data formats:

Freebase Demo

For this quick demo, a new F# ASP.NET project was created to show how to expose data from the Freebase API behind ServiceStack Web Services. This API also shows F#'s great integration with the FSharp.Data package. In the demo Games Service, we're returning a preview of the first 10 records from the Video Games list, showing the results in ServiceStack's Auto HTML page as well as in the built-in CSV format.

The steps used to create the demo boil down to:

  • Create a new project using an F# template from ServiceStackVS

  • Add the FSharp.Data NuGet package

    Install-Package FSharp.Data

Create our own Freebase client using our own API key:

type FreebaseDataWithKey = FreebaseDataProvider<Key="YouKeyGoesHere",LocalCache=true>

Create the Games Request DTO and make it available from the /games Route:

[<Route("/games")>]
type Games() = class end

Implement the Games Request method inside the existing MyServices Service and query Video Games from the Freebase API:

member this.Get(request : Games)=
    let data = FreebaseDataWithKey.GetDataContext()
    let result = query { 
        for e in data.``Arts and Entertainment``.``Video Games``.``Video Games`` do
            take 10
            select e } |> Seq.toList
    result

Summary

This demo shows off the advantages that come from ServiceStack's design and focus on simplicity as well as F#'s concise and readable syntax.


Download ServiceStackVS

ServiceStackVS supports both VS.NET 2013 and 2012 and can be downloaded from the Visual Studio Gallery

VS.NET Gallery Download

VS.NET 2012 Prerequisites.

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.