I created a simple local database by using SQLite.net - PCL, and inserted some data in it. My question is what is the easiest way to get one of the objects, or all of the obejects stored in the database?
My database:
namespace DatabaseDemo
{
public class Database
{
readonly SQLiteAsyncConnection _database;
public Database(string path)
{
_database = new SQLiteAsyncConnection(path);
_database.CreateTableAsync<Model>().Wait();
}
public Task<int> SaveItemAsync(Model person)
{
if (person.ID != 0)
{
return _database.UpdateAsync(person);
}
else
{
return _database.InsertAsync(person);
}
}
}
}
My Model class:
namespace DatabaseDemo
{
public class Model
{
[PrimaryKey, AutoIncrement]
public int ID { get; set; }
public string Name { get; set; }
}
}