![]() In Solution Explorer, in the LocalDatabaseTutorial project, expand App.xaml and double-click to open it. This path will be provided by the App class in the next exercise. In addition, the Database constructor takes the path of the database file as an argument. The code uses asynchronous SQLite.NET APIs that move database operations to background threads. This class contains code to create the database, read data from it, and write data to it. Public Task SavePersonAsync(Person person) _database = new SQLiteAsyncConnection(dbPath) ![]() Readonly SQLiteAsyncConnection _database Then, in Database.cs, remove all of the template code and replace it with the following code: using In Solution Explorer, in the LocalDatabaseTutorial project, add a new class named Database to the project. ![]() The ID property is marked with PrimaryKey and AutoIncrement attributes to ensure that each Person instance in the database will have a unique id provided by SQLite.NET. This code defines a Person class that will store data about each person in the application. Then, in Person.cs, remove all of the template code and replace it with the following code: using SQLite In Solution Explorer, in the LocalDatabaseTutorial project, add a new class named Person to the project.
0 Comments
Leave a Reply. |