Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Web API Development with ASP.NET Core 8

You're reading from  Web API Development with ASP.NET Core 8

Product type Book
Published in Apr 2024
Publisher Packt
ISBN-13 9781804610954
Pages 804 pages
Edition 1st Edition
Languages
Author (1):
Xiaodi Yan Xiaodi Yan
Profile icon Xiaodi Yan

Table of Contents (20) Chapters

Preface 1. Chapter 1: Fundamentals of Web APIs 2. Chapter 2: Getting Started with ASP.NET Core Web APIs 3. Chapter 3: ASP.NET Core Fundamentals (Part 1) 4. Chapter 4: ASP.NET Core Fundamentals (Part 2) 5. Chapter 5: Data Access in ASP.NET Core (Part 1: Entity Framework Core Fundamentals) 6. Chapter 6: Data Access in ASP.NET Core (Part 2 – Entity Relationships) 7. Chapter 7: Data Access in ASP.NET Core (Part 3: Tips) 8. Chapter 8: Security and Identity in ASP.NET Core 9. Chapter 9: Testing in ASP.NET Core (Part 1 – Unit Testing) 10. Chapter 10: Testing in ASP.NET Core (Part 2 – Integration Testing) 11. Chapter 11: Getting Started with gRPC 12. Chapter 12: Getting Started with GraphQL 13. Chapter 13: Getting Started with SignalR 14. Chapter 14: CI/CD for ASP.NET Core Using Azure Pipelines and GitHub Actions 15. Chapter 15: ASP.NET Core Web API Common Practices 16. Chapter 16: Error Handling, Monitoring, and Observability 17. Chapter 17: Cloud-Native Patterns 18. Index 19. Other Books You May Enjoy

Basic LINQ queries

This book is not intended to be a LINQ handbook. However, we will show you some basic LINQ queries in this section:

  • Querying the data
  • Filtering the data
  • Sorting the data
  • Paging the data
  • Creating the data
  • Updating the data
  • Deleting the data

Querying the data

The DbSet<Invoice> Invoices property in the InvoiceDbContext class represents a collection of the Invoice entity. We can use LINQ methods to query the data. For example, we can use the ToListAsync() method to retrieve all the invoices from the database:

var invoices = await _context.Invoices.ToListAsync();

That is how the GetInvoices action method works.

To find a specific invoice, we can use the FindAsync() method, as shown in the GetInvoice() action method:

var invoice = await _context.Invoices.FindAsync(id);

The FindAsync() method accepts the primary key value as the parameter. EF Core will translate the FindAsync() method to the SQL SELECT statement...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}