Querying data

If you've ever used Language Integrated Query (LINQ) before, you'll feel right at home with EF Core. The DbSet collection, which we've used to manipulate objects' states, implements the IQueryable interface that defines many querying operators that are later transformed into SQL statements by the database provider you've used. 

For example, the GiveNTake application allows the user to search for products that were published on a specific date. Here is a shortened version of how it is done:

[HttpGet("search/{date:datetime}/{keyword}/")]public async Task<IActionResult> Search(DateTime date, string keyword){    var products = await _context.Products              .Where(p => p.Title.Contains(keyword)) .Where(p => p.PublishDate.Date == date.Date) ...

Get Hands-On Full-Stack Web Development with ASP.NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.