Skip to content

Instantly share code, notes, and snippets.

@avegaraju
Last active December 23, 2018 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avegaraju/03d60370b3d794575affc1e505975c0c to your computer and use it in GitHub Desktop.
Save avegaraju/03d60370b3d794575affc1e505975c0c to your computer and use it in GitHub Desktop.
module DB
open System.Data.Common
open Dapper
open Rows
open Domain
let allProducts(connection: DbConnection) =
let getProductType productType =
match productType with
| "Parcel" -> ProductType.Parcel
| "WhiteGood" -> ProductType.WhiteGood
| "XL" -> ProductType.XL
| _ -> ProductType.XL
try
connection.Query<ProductRow>("select * from products")
|> Seq.map(fun i-> new Product(i.ProductId, i.Name, i.Height, i.Weight, i.Length, i.Width, getProductType i.ProductType))
|> fun i-> Ok(i)
with
| ex -> Error ex
//Other methods removed for brevity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment