Skip to content

Instantly share code, notes, and snippets.

@rid00z
Created August 19, 2014 11:42
Show Gist options
  • Save rid00z/8f8cfdaf965e11ca63fe to your computer and use it in GitHub Desktop.
Save rid00z/8f8cfdaf965e11ca63fe to your computer and use it in GitHub Desktop.
Local Data Source
public class LocalDataSource : IDataSource
{
SQLiteConnection _sqliteConnection;
public LocalDataSource ()
{
_sqliteConnection = Xamarin.Forms.DependencyService.Get<ISQLiteFactory> ().GetConnection("app.db");
CreateTable ();
}
void CreateTable ()
{
_sqliteConnection.CreateTable<JellyBeanValue> ();
_sqliteConnection.CreateTable<MyJellyBean> ();
}
public Task<IEnumerable<JellyBeanValue>> GetJellyBeanValues ()
{
return Task.FromResult((IEnumerable<JellyBeanValue>)_sqliteConnection.Table<JellyBeanValue> ());
}
public Task<IEnumerable<MyJellyBean>> GetMyJellyBeans ()
{
return Task.FromResult((IEnumerable<MyJellyBean>)_sqliteConnection.Table<MyJellyBean> ());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment