Created
July 5, 2020 21:57
-
-
Save isaacabraham/7af54b8bc1507ceee546e562796b4c0e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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