United Kingdom: +44 (0)208 088 8978

SQL Server and F# Series

In this blog, Akash sets the scene for his upcoming SQL Server series and gives a sneak peek of what to expect! 👀

Coming from a JavaScript background, my go-to choice for storage was MongoDB. It was quick and easy to setup and worked nicely with JavaScript's dynamic nature. Having never used SQL storage, I felt I was missing a vital understanding as to why things like Mongo even existed.

When I started at Compositional IT, where we often use SQL Server, I got the chance to improve my SQL knowledge. I wasn't sure where to start, and as always the F# community have done an incredible job at providing so many different technologies to choose from.

In this blog series I plan to go through some of the most popular F# SQL data access layers and some that may be new to you!

I'll be using the same domain for each technology. That way we'll gain familiarity with the code and can focus on the data side of things. I've tried to include as many F# features as possible, such as Single cased unions and Options, without overcomplicating the design to see how each technology handles the mapping.

Domain

type PokemonTrainerId = PokemonTrainerId of Guid
type PokeIndex = PokeIndex of int

type PokemonType =
    | Rock
    | Grass
    | Poison
    | Fire
    | Psychic
    | Ghost
    | Ice

type Pokemon =
    { PokeIndex : PokeIndex
      Name : string
      Level: int
      PokemonTypes: PokemonType list
      EvolutionName: string option }

type Record = 
    { Wins: uint; Losses: uint }

type PokemonTrainer =
    { Id : PokemonTrainerId
      Name : string
      Pokemon : Pokemon list
      Record: Record }

Sneak preview

In my upcoming blogs you can expect to see how F# can be used with:

  • Raw ADO.NET
  • ADO.NET extensions - Donald
  • Micro ORMs - Dapper
  • Full ORMs - SQLProvider
  • Code generation - Facil

In my next blog we'll set up SQL Server with Visual Studio!