public async Task<int> AddAsync(Raincheck raincheck) { var addedRaincheck = _context.RainChecks.Add(raincheck); await _context.SaveChangesAsync(CancellationToken.None); return addedRaincheck.Entity.RaincheckId; }
/// <summary> /// Lazy loading is not currently available with EF 7.0, so this loads the Store/Product/Category information /// </summary> private async Task FillRaincheckValuesAsync(Raincheck raincheck) { raincheck.IssuerStore = await _context.Stores.AsAsyncEnumerable().First(s => s.StoreId == raincheck.StoreId); raincheck.Product = await _context.Products.AsAsyncEnumerable().First(p => p.ProductId == raincheck.ProductId); raincheck.Product.Category = await _context.Categories.AsAsyncEnumerable().First(c => c.CategoryId == raincheck.Product.CategoryId); }