Created
August 19, 2014 11:42
-
-
Save rid00z/8f8cfdaf965e11ca63fe to your computer and use it in GitHub Desktop.
Local Data Source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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