Last active
December 23, 2018 23:07
-
-
Save avegaraju/03d60370b3d794575affc1e505975c0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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