Skip to content

Instantly share code, notes, and snippets.

@isaacabraham
Created July 5, 2020 21:57
Show Gist options
  • Select an option

  • Save isaacabraham/7af54b8bc1507ceee546e562796b4c0e to your computer and use it in GitHub Desktop.

Select an option

Save isaacabraham/7af54b8bc1507ceee546e562796b4c0e to your computer and use it in GitHub Desktop.
module rec Program
open Microsoft.EntityFrameworkCore
type BloggingContext =
{ Blogs : DbSet<Blog>
Posts : DbSet<Post> }
let configureDb (optionsBuilder:DbContextOptionsBuilder) =
optionsBuilder.UseSqlServer @"Server=(localdb)\mssqllocaldb;Database=Blogging;Integrated Security=True"
|> ignore
type Blog =
{ BlogId : int
Url : string
Rating : int
Posts : ResizeArray<Post> }
type Post =
{ PostId : int
Title : string
Content : string
BlogId : int
Blog : Blog }
let ctx : BloggingContext = failwith "oops!"
let blogs =
query {
for blog in ctx.Blogs do
where (blog.Rating > 3)
sortBy blog.Url
} |> Seq.toList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment