Last active
August 29, 2015 13:57
-
-
Save jjvdangelo/9383142 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
// --Snip-- | |
let getEntity id = | |
use conn = EntityContext.GetDataContext() | |
query { for t1 in conn.Table_1 do | |
join t2 in conn.Table_2 on (t1.id = t2.table_1_id) | |
where (t1.id = id) | |
select t2 | |
headOrDefault } |> function | |
| null -> Unchecked.defaultof<_> | |
| t2 -> { Id = t2.id; Value = t2.value } | |
interface IGet with | |
member this.Get() = | |
this.Result <- this.Id |> getEntity | |
match this.Result = Unchecked.defaultof<_> with | |
| true -> Status 413 | |
| false -> Status 200 |
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
namespace BlowingUpSqlEntityConnection.Web | |
open Simple.Web | |
open BlowingUpSqlEntityConnection.Web.Data | |
type Result = { Id: int; Value: int } | |
[<UriTemplate("/foo/{Id}/bars")>] | |
type Index() as this = | |
let getEntity() = | |
use conn = EntityContext.GetDataContext() | |
query { for t1 in conn.Table_1 do | |
join t2 in conn.Table_2 on (t1.id = t2.table_1_id) | |
where (t1.id = this.Id) | |
select t2 | |
headOrDefault } |> function | |
| null -> Unchecked.defaultof<_> | |
| t2 -> { Id = t2.id; Value = t2.value } | |
member val Id = null with get, set | |
member val Result = Unchecked.defaultof<_> with get, set | |
interface IGet with | |
member this.Get() = | |
this.Result <- getEntity() | |
match this.Result = Unchecked.defaultof<_> with | |
| true -> Status 413 | |
| false -> Status 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment