Skip to content

Instantly share code, notes, and snippets.

@avegaraju

avegaraju/DBModule.fs

Last active Dec 23, 2018
Embed
What would you like to do?
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