Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
.NET MAUI Cookbook

You're reading from   .NET MAUI Cookbook Build a full-featured app swiftly with MVVM, CRUD, AI, authentication, real-time updates, and more

Arrow left icon
Product type Paperback
Published in Dec 2024
Publisher Packt
ISBN-13 9781835461129
Length 384 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Alexander Russkov Alexander Russkov
Author Profile Icon Alexander Russkov
Alexander Russkov
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Chapter 1: Crafting the Page Layout FREE CHAPTER 2. Chapter 2: Mastering the MVVM Design Pattern 3. Chapter 3: Advanced XAML and UI Techniques 4. Chapter 4: Connecting to a Database and Implementing CRUD Operations 5. Chapter 5: Authentication and Authorization 6. Chapter 6: Real-Life Scenarios: AI, SignalR, and More 7. Chapter 7: Understanding Platform-Specific APIs and Custom Handlers 8. Chapter 8: Optimizing Performance 9. Index 10. Other Books You May Enjoy

Connecting to a Database and Implementing CRUD Operations

How many apps on your phone don’t store information in some sort of database? Probably not many. Even simple apps, such as calculators, often save a history of operations.

Back in 2022, when .NET MAUI had its first official release, I built a simple .NET MAUI application. I was surprised to encounter noticeable lags despite the UI being relatively simple. After profiling the app, I discovered that the problem lay in how I was loading data from the database. In this chapter, I will describe how to avoid the issues I encountered and implement best practices for database communication.

In each recipe covered in this chapter, we will build on the project from the previous step. By the end of this chapter, you’ll have implemented a CRUD application that retrieves information from both local and remote storage. You’ll learn how to create separate views to display and edit information, and how to effectively pass data and updates between these views. We’ll also implement the unit of work and repository patterns with caching support, showing you how these patterns make it easy to replace one data retrieval mechanism with another.

In this chapter, we’ll be covering the following topics:

  • Connecting to a local SQLite database via Entity Framework Core (EF Core)
  • Implementing create and delete operations
  • Implementing detail and edit forms
  • Implementing the unit of work and repository patterns
  • Handling errors while saving data to a database
  • Validating editors in the UI before data posting
  • Implementing data caching for enhanced performance
  • Connecting to a remote web API service
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 $19.99/month. Cancel anytime
Banner background image