private void LoadPersistedJobs(IPlatformModuleEntities platformModuleEntities) { using (var dbcontext = _contextFactory.CreateContext()) { var jobs = dbcontext.GetQuery <Job>().Include(j => j.JobItems).ToList(); foreach (var job in jobs) { _jobs.Add(job.JobId, job); _logger.DebugFormat("loaded job: {0}", job.JobId); } } }
protected void SaveRecipeToDb(Route recipe, PlatformItem item) { var context = _contextFactory.CreateContext(); foreach (var recipeItem in recipe.RouteItems) { lock (_locking) { recipeItem.Id = ++_recipeItemId; } context.Add(recipeItem); } recipe.Id = item.ItemId; context.Add(recipe); context.Attach(item); context.SaveChangesAsync(); }
protected WorkflowFactoryBase(IEntityContextFactory contextFactory, ILogger logger) { _logger = logger; _contextFactory = contextFactory; lock (_locking) { if (_recipeItemId == 0) { using (var context = _contextFactory.CreateContext()) { var recipeItems = context.GetQuery <RouteItem>(); _recipeItemId = recipeItems.Any() ? recipeItems.Max(a => a.Id) : 1; context.SaveChanges(); } } } }