コード例 #1
0
        public async Task SavePriceAndTax(PriceAndTaxes priceAndTax)
        {
            using (var context = new PriceAndTaxDbContext(_options))
            {
                await context.PriceAndTaxes.AddAsync(priceAndTax);

                await context.SaveChangesAsync();
            }
        }
コード例 #2
0
        public async Task <PriceAndTaxes> GetPriceAndTax(DateTime timestamp, string type)
        {
            using (var context = new PriceAndTaxDbContext(_options))
            {
                var priceAndTax = await context.PriceAndTaxes.Where(pnt => pnt.TimeStamp <= timestamp && pnt.Type == type).ToListAsync();

                Console.WriteLine("PriceAndTax nearest to {" + timestamp.ToString() + "} is from {" + priceAndTax.Last().TimeStamp.ToString() + "}");
                return(priceAndTax.Last());
            }
        }
コード例 #3
0
        public bool CreateDB()
        {
            using (var context = new PriceAndTaxDbContext(_options))
            {
                if (true && (context.GetService <IDatabaseCreator>() as RelationalDatabaseCreator).Exists())
                {
                    return(false);
                }

                context.Database.EnsureDeleted();
                return(context.Database.EnsureCreated());
            }
        }