private void QueryData() { using (var context = new ARCHONEntities()) { _queryData = ( from jobStep in context.JobSteps join executionModule in context.ExecutionModules on jobStep.ModuleUID equals executionModule.ModuleUID join job in context.Jobs on jobStep.JobUID equals job.JobUID where !job.IsDeleted && job.IsLive && !jobStep.IsDeleted && jobStep.IsLive select new ExecMethodDto { JobId = job.JobUID, JobName = job.JobName, StepId = jobStep.StepUID, Category = job.Category, ModuleId = jobStep.ModuleUID, ModuleName = executionModule.ModuleName, ModuleAssembly = executionModule.ModuleAssembly, ModuleObject = executionModule.ModuleObject, ConfigFile = jobStep.ConfigurationFile }) .OrderBy(dto => dto.ModuleObject) .ToList(); } }
private void PopulateJobConditionsDictionary() { // Get the partitioner. var partitioner = Partitioner.Create(JobConversionHelper.ArchonJobDictionary); // creation strategies. var partitions = partitioner.GetPartitions(Environment.ProcessorCount * 3); // Create a task for each partition. var tasks = partitions.Select(p => Task.Run(() => { // Create the context. using (var ctx = new ARCHONEntities()) // Remember, the IEnumerator<T> implementation // might implement IDisposable. // While there are items in p. { while (p.MoveNext()) { // Get the current item. var current = p.Current; var jobFreq = new JobFreqDto(current.Value, ctx); _jobConditions.TryAdd(current.Key, jobFreq); } } })). // ToArray is needed (or something to materialize the list) to // avoid deferred execution. ToArray(); Task.WaitAll(tasks); }