コード例 #1
0
        public static async Task SeedAsync(CloudContext CloudContext,
                                           ILoggerFactory loggerFactory, int?retry = 0)
        {
            int retryForAvailability = retry.Value;

            try
            {
                // TODO: Only run this if using a real database
                // context.Database.Migrate();

                if (!CloudContext.CatalogBrands.Any())
                {
                    CloudContext.CatalogBrands.AddRange(
                        GetPreconfiguredCatalogBrands());

                    await CloudContext.SaveChangesAsync();
                }

                if (!CloudContext.CatalogTypes.Any())
                {
                    CloudContext.CatalogTypes.AddRange(
                        GetPreconfiguredCatalogTypes());

                    await CloudContext.SaveChangesAsync();
                }

                if (!CloudContext.CatalogItems.Any())
                {
                    CloudContext.CatalogItems.AddRange(
                        GetPreconfiguredItems());

                    await CloudContext.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                if (retryForAvailability < 10)
                {
                    retryForAvailability++;
                    var log = loggerFactory.CreateLogger <CloudContextSeed>();
                    log.LogError(ex.Message);
                    await SeedAsync(CloudContext, loggerFactory, retryForAvailability);
                }
            }
        }
コード例 #2
0
 public EfRepository(CloudContext dbContext)
 {
     _dbContext = dbContext;
 }
コード例 #3
0
 public OrderRepository(CloudContext dbContext) : base(dbContext)
 {
 }