yan cus

yan cus

  • NA
  • 124
  • 2.9k

How to save and clean a specific database if there are 2 or more data?

Jan 9 2021 3:57 AM
How to save and clean a specific database if there are 2 or more data models in one database file.
 
previously I have created a data model as below. I have successfully loaded the data into a listView for the public class student.
 
Then, how do you access data from a public class school that is only input once without using a listView and PrimaryKey?
  1. using SQLite;  
  2. using System;  
  3. namespace SchoolData.Models {  
  4.   public class Student {  
  5.     [PrimaryKey, AutoIncrement] public int IdSis {  
  6.       get;  
  7.       set;  
  8.     }  
  9.     public DateTime Date {  
  10.       get;  
  11.       set;  
  12.     }  
  13.     public string PicStudent {  
  14.       get;  
  15.       set;  
  16.     }  
  17.   }  
  18.   public class School {  
  19.     public string SchoolName {  
  20.       get;  
  21.       set;  
  22.     }  
  23.     //without primary key or single entry   
  24.     public string Address {  
  25.       get;  
  26.       set;  
  27.     }  
  28.     public string Vision {  
  29.       get;  
  30.       set;  
  31.     }  
  32.   }  
  33. }  
XamlPage code overview:
  1. <StackLayout>  
  2. <Label Text="School Name:"/>  
  3. <Entry Text="{Binding SchoolName}"/>  
  4. <Label Text="Address:"/>  
  5. <Entry Text="{Binding Address}"/>  
  6. <Label Text="Vision:"/>  
  7. <Entry Text="{Binding Vision}"/>  
  8. <Button Text="Save" Clicked="SaveClick"/>  
  9. //save all entry  
  10. <Button Text="Clear" Clicked="ClearClick"/> //clear all entry  
  11. </StackLayout>  
Thank's.

Answers (6)