private Dictionary <string, MLPredictionState> GetPredictionStateList(List <MLPredictionState> list)
        {
            var statesToProcess = new List <MLPredictionState>(list);
            var result          = new Dictionary <string, MLPredictionState>();

            foreach (var kv in _dbToResultMapping)
            {
                string         dbSignificance       = kv.Key;
                MLSignificance responseSignificance = kv.Value;
                result.AddRange(GetPredictionState(statesToProcess, dbSignificance, responseSignificance));
                statesToProcess.RemoveAll(state => result.Values.Any(
                                              resultState => resultState.ModelId == state.ModelId));
            }
            var stateComparer = new MLPredictionStateComparer();

            result.AddRange(statesToProcess.Distinct(stateComparer).Select(state => new MLPredictionState {
                ModelId = state.ModelId,
                State   = MLSignificance.InProgress
            }).ToDictionary(l => l.ModelId.ToString()));
            return(result);
        }
        private Dictionary <string, MLPredictionState> GetPredictionState(IEnumerable <MLPredictionState> list,
                                                                          string dbSignificance, MLSignificance responseSignificance)
        {
            var result = from item in list
                         join signigicantItem in list on new { ModelId = item.ModelId, Significance = dbSignificance }
            equals new { ModelId = signigicantItem.ModelId, Significance = signigicantItem.Significance }
            into significantList
            from significantItem in significantList.DefaultIfEmpty(new MLPredictionState()
            {
                Value = Guid.Empty
            })
            group new { item, significantItem } by item.ModelId into groupedList
                select new MLPredictionState {
                ModelId = groupedList.Key,
                Value   = responseSignificance == MLSignificance.Exact
                                                                ? groupedList.Max(groupedItem => groupedItem.significantItem.Value)
                                                                : Guid.Empty,
                State = groupedList.Count(groupedItem => groupedItem.significantItem.Value != Guid.Empty) == 0
                                                                ? MLSignificance.Unknown
                                                                : responseSignificance
            };

            return(result.Where(r => r.State != MLSignificance.Unknown).ToDictionary(r => r.ModelId.ToString()));
        }