Get all duplicate records from database into a List of Lists
0
So i needed to write a method that gets all people that have the same email as each other and I came up with this: // This is from our Framework, as we're not actually using // But this is basically a `Person.Where(x => x.IsActive)` query // And returns all persons that are active var people = Querier.Person.AttrQuery(x => x.IsActive).AsQueryable<Person>().ToList()M // A 2D List, where every inner list is a set of duplicate people var duplicates = new List<List<Person>> {new List<Person>()}; var last = new Person(); foreach (var person in people) { if (person.Email == last.Email) duplicates.Last().Add(person); else duplicates.Add(new List<Person>()); } // Remove all empty Lists and all Lists without any duplicates duplicates = dup...