public class MedicineTransation{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public string name {get;set;}
public int age {get;set;}
public string grade {get;set;}
}
// StudentViewController
//Add student Record to student database.
btn_AddRecord.TouchUpInside += ((object sender, EventArgs e) => {
string folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
var db = new SQLiteConnection (System.IO.Path.Combine (folder, "student.db"));
db.CreateTable<MedicineTransation>();
var student = new Student {
name = studentName;
age = studentage;
grade = studentGrade;
};
db.Insert (student);
)};
//DetailedViewController
//Delete student Record to student database.
btn_DeleteRecord.TouchUpInside += ((object sender, EventArgs e) => {
// db.Insert (student); Insert Record into database.
// db.Delete (student); Delete Record from database.
}
Chcesz uzyskać dostęp do tej samej bazy danych z innego kontrolera widoku.
Odpowiedzi:
0 dla odpowiedzi № 1Możesz zaimplementować wzorzec repozytorium.
http://msdn.microsoft.com/en-us/library/ff649690.aspx
Alternatywnie (jeśli ten wzorzec jest przesadny), możesz stworzyć klasę modelu i pozwolić sobie zarządzać metodami statycznymi lub osobnym singletonem.