private static async Task Seed(int n = 1000) { for (var i = 0; i < n; i++) { var context = new PlaygroundContext(new DbContextOptionsBuilder <PlaygroundContext>() .UseNpgsql("Host=localhost;Database=playground;Username=postgres;Password=LocalDev123", o => o.UseNodaTime()) .UseSnakeCaseNamingConvention() .EnableSensitiveDataLogging().Options); var recipe = new Recipe(name: Company.Name()); recipe.Description = Company.BS(); recipe.CookTime = Duration.FromMinutes(RandomNumber.Next(1, 60)); recipe.PrepTime = Duration.FromMinutes(RandomNumber.Next(1, 60)); var ingredientCount = RandomNumber.Next(3, 8); for (var j = 0; j < ingredientCount; j++) { var ingredientName = Name.FullName(); var existing = await context.Ingredients.FirstOrDefaultAsync(i => i.Name == ingredientName); var ingredient = existing ?? new Ingredient(ingredientName); var units = Enum.Random <UnitOfMeasure>(); var quantity = RandomNumber.Next(1, 16) / 4.0M; recipe.AddIngredient(ingredient, units, quantity); } Console.WriteLine($"Entering recipe {i} of {n}"); context.Recipes.Add(recipe); await context.SaveChangesAsync(); } }
public static DbContext GetDbContext() { new FakeData().PopulateFakeData(new PlaygroundContext()); var ctx = new PlaygroundContext(); return(ctx); }
public TestController(PlaygroundContext context, UserManager <IdentityUser> userManager, RoleManager <IdentityRole> roleManager, IMemoryCache memoryCache) { this.context = context; this.userManager = userManager; this.roleManager = roleManager; this.memoryCache = memoryCache; }
public void Setup() { var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); var builder = new DbContextOptionsBuilder <PlaygroundContext>(); builder.UseNpgsql(configuration.GetConnectionString("PostgreSQLConnection")); db_context = new PlaygroundContext(builder.Options); }
public void JoinedQuery() { var key = RandomKey(); using var context = new PlaygroundContext(_dbOptions); var recipe = context.Recipes .Include(r => r.RecipeIngredients) .First(r => r.Key == key); }
public SplitQueryBenchmark() { _dbOptions = new DbContextOptionsBuilder <PlaygroundContext>() .UseNpgsql("Host=localhost;Database=playground;Username=postgres;Password=LocalDev123", o => o.UseNodaTime()) .UseSnakeCaseNamingConvention() .EnableSensitiveDataLogging().Options; using var context = new PlaygroundContext(_dbOptions); _keys = context.Recipes.Select(r => r.Key).Take(200).ToArray(); }
private static async Task Main(string[] args) { var context = new PlaygroundContext(new DbContextOptionsBuilder <PlaygroundContext>() .UseNpgsql("Host=localhost;Database=playground;Username=postgres;Password=LocalDev123", o => o.UseNodaTime()) .UseSnakeCaseNamingConvention() .EnableSensitiveDataLogging().Options); var path = @"/Users/matt.burke/projects/misc/ConsoleApplication1"; var indexPath = Path.Combine(path, "recipe-index"); Console.WriteLine(indexPath); var sharedWriter = new SharedLuceneWriter(indexPath); // var indexer = new IndexAllRecipes(context, new RecipeIndexer(sharedWriter)); // await indexer.IndexAll(); var searcher = new RecipeIndexSearcher(sharedWriter); foreach (var result in searcher.Search("potato").Results) { Console.WriteLine($"{result.Name} ({result.Key})"); Console.WriteLine(result.Description); Console.WriteLine(result.IngredientNames); Console.WriteLine("----------"); } // BenchmarkRunner.Run<SplitQueryBenchmark>(); // await Seed(10_000); return; // context.Customers.Add(customer); // await context.SaveChangesAsync(); //await Task.Delay(1000); }
public IndexRecipeChangedHandler(RecipeIndexer recipeIndexer, PlaygroundContext context) { _recipeIndexer = recipeIndexer; _context = context; }
public ReviewRepositoryTests(ServiceProviderFixture fixture) { _reviewGenerator = fixture.Provider.GetService <IModelGenerator <Review> >(); _reviewRepository = fixture.Provider.GetService <IUnitOfWork>().ReviewRepository; _context = fixture.Provider.GetService <PlaygroundContext>(); }
public ReviewRepository(PlaygroundContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }
public GoodsRepository(PlaygroundContext db_context) { _db_Context = db_context; }
public IndexAllRecipes(PlaygroundContext context, RecipeIndexer indexer) { _context = context; _indexer = indexer; }
public PermissionController(IEmegenlerFluentApi api, PlaygroundContext context) { API = api; _context = context; }
public RemoveRecipeRequestHandler(PlaygroundContext context) { _context = context; }
public AuthController(IEmegenlerFluentApi api, PlaygroundContext context) { API = api; _context = context; }
public SearchRecipeHandler(RecipeIndexSearcher searcher, PlaygroundContext context, IMapper _mapper) { _searcher = searcher; _context = context; this._mapper = _mapper; }
public CreateRecipeCommandHandler(IMapper mapper, PlaygroundContext context) { _mapper = mapper; _context = context; }
public RemoveIngredientRequestHandler(IMapper mapper, PlaygroundContext context) { _mapper = mapper; _context = context; }
public PlaygroundProvider(PlaygroundContext context) { _context = context; }
public GameRepositoryTests(ServiceProviderFixture fixture) { _gameGenerator = fixture.Provider.GetService <IModelGenerator <Game> >(); _gameRepository = fixture.Provider.GetService <IUnitOfWork>().GameRepository; _context = fixture.Provider.GetService <PlaygroundContext>(); }
public AddIngredientHandler(IMapper mapper, PlaygroundContext context) { _mapper = mapper; _context = context; }
public GetRecipeRequestHandler(PlaygroundContext context, IMapper mapper) { _context = context; _mapper = mapper; }