public static bool RemoveTmpPPDuplications(ProtecaDomainContext domainContext, Action<int> foundItemsToDelete = null, Action itemDeleted = null)
 {
     var ppTmpGrps = CreateIntegrityData(domainContext);
     var firstItemsToDelete = ppTmpGrps.SelectMany(ppTmpGrp => ppTmpGrp.GetObsoleteItemsToDeleteDirect()).ToList();
     var conflictsAutoResolved = ppTmpGrps.Where(ppTmpGrp => ppTmpGrp.NeedChoice).SelectMany(ppTmpGrp => ppTmpGrp.GetObsoleteItemsToDeleteAutoChoice()).ToList();
     var conflictedItems = ppTmpGrps.Where(ppTmpGrp => ppTmpGrp.NeedChoice && !ppTmpGrp.AutoChoiceFound).ToList();
     var itemsToDelete = firstItemsToDelete.Concat(conflictsAutoResolved);
     if (foundItemsToDelete != null)
         foundItemsToDelete(itemsToDelete.Count());
     foreach (var ppTmpToDelete in itemsToDelete)
     {
         domainContext.PpTmps.Remove(ppTmpToDelete);
         if (itemDeleted != null)
             itemDeleted();
     }
     return itemsToDelete.Any();
 }
 private static List<PpDataCheckInfo> CreateIntegrityData(ProtecaDomainContext domainContext)
 {
     return domainContext.EntityContainer.GetChanges().OfType<PpTmp>()
         .GroupBy(
             pp => pp.Pp,
             (pp, grp) => new PpDataCheckInfo
             {
                 PP = pp,
                 Groups = grp
                     .GroupBy(pptmp => GetValuesAsString(pptmp), (title, pptmps) => new PpTmpGroupInfo { Values = pptmps.ToList() })
                     .ToList()
             })
         .ToList();
 }