liveBook · Manning

CRUD

As explained in Building Web APIs with ASP.NET Core

CRUD is the set of create, read, update, and delete operations used to manage persistent data.

CRUD names the four persistent-data operations: create, read, update, and delete. In a board-game web API, these operations let application services interact with database records without exposing the database directly. section 5.0 section 1.1.2

Map each CRUD operation to its database query and typical HTTP method:

  • Create uses INSERT and commonly handles HTTP POST requests. section 5.0
  • Read uses SELECT and commonly handles HTTP GET requests. section 5.0
  • Update uses UPDATE and commonly handles HTTP PUT requests. section 5.0
  • Delete uses DELETE and commonly handles HTTP DELETE requests. section 5.0

Implement these operations through EF Core and LINQ rather than writing raw SQL. Inject ApplicationDbContext into controllers, then use IEnumerable<T> for in-memory collections and IQueryable<T> to build queries translated for the database. section 5.0 section 5.7

Seeding board-game records

A create workflow can read a CSV file with CsvHelper, map each record to a DTO, construct BoardGame entities, and add them through ApplicationDbContext. After executing the workflow, the database contains records that read, update, and delete actions can manage. section 5.7

Figure 1.3 Several board-game-related web applications and services fed by a single MyBGList web API
01-03

Trace how one web API feeds a public website, mobile app, management portal, and analysis service while keeping the database behind the API. section 1.1.2

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Explains EF Core, LINQ, dependency injection, and CSV seeding, while assuming basic DML knowledge and avoiding required SQL syntax.
Examples
Uses CSV board-game seeding, BoardGame entities, web API clients, and a restricted management portal as concrete examples.
What it assumes
Assumes basic DML knowledge while requiring no specific SQL knowledge because LINQ handles the database tasks.
What you can do after
Build it from scratch by seeding records and implementing HTTP-backed create, read, update, and delete actions with EF Core.
How it connects
Connects CRUD with EF Core, LINQ, ApplicationDbContext, dependency injection, DTOs, HTTP methods, and SQL DML.

Also explained in

Compare how 11 books explain CRUD →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.