コード例 #1
0
        public async Task <List <TaskModel> > GetTasksAsync()
        {
            using var db = await _indexedDbFactory.Create <TaskDb>();

            var result = db.Tasks.ToList();

            return(result);
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
 public async Task <IDatabase> CreateDatabase() => await _indexedDbFactory.Create <IndexedDatabase>();
コード例 #4
0
ファイル: Database.cs プロジェクト: iLogical/Enaq
 public async Task <T> OpenSession <T>() where T : IndexedDb
 {
     Console.WriteLine("Before");
     return(await _dbFactory.Create <T>());
 }