Welcome to Xamarin Guy Show Blog

Keep updated for latest and Greatest Posts from Xamarin guy

Dotnet MAUI One To Many Relation SQLITE PCL Database

Simple Example :

Think of a classroom like a group of students. Each group (or classroom) can have multiple students. For example, “Class A” can have Alice, Bob, and Emma as students. But Alice only belongs to “Class A” — she can’t be in “Class B” at the same time.

We will be adding this 3 packages inside our project:
<PackageReference Include=”sqlite-net-pcl” Version=”1.9.172″ />
<PackageReference Include=”SQLiteNetExtensions.Async” Version=”2.1.0″ />
<PackageReference Include=”SQLitePCLRaw.bundle_green” Version=”2.1.2″ />

MainPage.xaml

MainPage.xaml.cs

App.xaml.cs

ClassRoomViewModel.cs

Now we will be creating 2 tables : Student.cs, and ClassRoomItem.cs tables

Student.cs

ClassRoomItem.cs

Finally our main database class for handling the crud operation and relation with database table ClassRoomDatabase.cs

Leave a Reply

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.