static void Main(string[] args) { var context = new BooksShopContext(); var books = context.Books.Count(); Console.WriteLine(books); }
// GET api/values/5 public IHttpActionResult Get(int id) { var context = new BooksShopContext(); var author = context.Authors .Where(a => a.Id == id) .Select(a => "Id: " + a.Id + " - " + a.FirstName + " " + a.LastName); return(this.Ok(author)); }
public void Post([FromBody] Author author) { var context = new BooksShopContext(); context.Authors.Add(new Author() { FirstName = author.FirstName, LastName = author.LastName }); context.SaveChanges(); }