public async Task <IQueryable <Star> > GetSectorsAsync(long sxMin, long syMin, long sxMax, long syMax, [Service] UniverseContext dbContext, [Service] GalaxyGenerator generator) { var existingSectors = ( from s in dbContext.Stars where s.SectorX >= sxMin && s.SectorX <= sxMax && s.SectorY >= syMin && s.SectorY <= syMax group s by new { s.SectorX, s.SectorY } into g select new { g.Key.SectorX, g.Key.SectorY }).ToHashSet(); for (long sx = sxMin; sx <= sxMax; ++sx) { for (long sy = syMin; sy <= syMax; ++sy) { if (!existingSectors.Contains(new { SectorX = sx, SectorY = sy })) { await generator.GenerateSector(sx, sy, dbContext); } } } return(dbContext.Stars .Where(s => s.SectorX >= sxMin && s.SectorX <= sxMax && s.SectorY >= syMin && s.SectorY <= syMax)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, UniverseContext db) { db.Database.EnsureCreated(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors(o => o .AllowAnyHeader() .AllowAnyMethod() .AllowAnyOrigin()); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseRouting(); app.UseGraphQL() .UsePlayground(); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; }); }
public GameUpdate(UniverseContext dbContext, GameConfiguration gameConfig) { _dbContext = dbContext; _gameConfig = gameConfig; }
public IQueryable <Ship> GetShips([Service] UniverseContext dbContext) => dbContext.Ships;
public IQueryable <PlanetMeta> GetPlanetMeta([Service] UniverseContext dbContext) => dbContext.PlanetMetas;
public IQueryable <Planet> GetPlanet([Service] UniverseContext dbContext) => dbContext.Planets;
public IQueryable <Star> GetStars([Service] UniverseContext dbContext) => dbContext.Stars;