public void Salvar() { using (var db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid(), _caminhoBanco, storeDateTimeAsTicks: false)) { db.Execute("DELETE FROM Estabelecimento"); db.InsertAll(Estabelecimentos); db.Execute("DELETE FROM Gasto"); foreach (var gasto in Gastos) { gasto.EstabelecimentoId = gasto.Estabelecimento.Id; } db.InsertAll(Gastos); } }
private static void CreateDatabaseFromJson(string dbFileName) { //CleverWeather.SiteListUtils.ForecastTest(System.Console.Out); var connection = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.Win32.SQLitePlatformWin32(), dbFileName); //Create tables and populate city table if needed if (connection.RowCount <City>() == 0) { //Create tables connection.CreateTable <City>(); connection.CreateTable <CurrentConditions>(); connection.CreateTable <Forecast>(); var assembly = System.Reflection.Assembly.GetAssembly(typeof(CleverWeather.SiteListUtils)); connection.InsertAll(CleverWeather.SiteListUtils.GetEmbeddedCitiesResource(assembly), typeof(City)); } }