public async Task <List <TaskModel> > GetTasksAsync() { using var db = await _indexedDbFactory.Create <TaskDb>(); var result = db.Tasks.ToList(); return(result); }
public async Task InitializeDbASync() { using var db = await _dbFactory.Create <SampleDbContext>(); if (db.Countries.Count > 0 && db.Airports.Count > 0) { return; } var countries = await _httpClient.GetFromJsonAsync <Country[]>("sample-data/airports.json"); if (countries != null) { foreach (var country in countries) { var countryId = Guid.NewGuid(); db.Countries.Add(new Country { Id = countryId, Name = country.Name, }); foreach (var airport in country.Airports) { db.Airports.Add(new Airport { Id = Guid.NewGuid(), City = airport.City, Name = airport.Name, State = airport.State, ShortName = airport.ShortName, CountryId = countryId }); } } await db.SaveChanges(); } }
public async Task <IDatabase> CreateDatabase() => await _indexedDbFactory.Create <IndexedDatabase>();
public async Task <T> OpenSession <T>() where T : IndexedDb { Console.WriteLine("Before"); return(await _dbFactory.Create <T>()); }