Function 1: public HttpResponseMessage Get340BValidations()        {            int partitionId = GetPartitionId();            //int partitionId = 10054;            this.db.Database.CommandTimeout = 180;            List<Validation340B> result = this.db.VW_Validation_340B.Where(x => x.partition_id == partitionId).ToList();var duplicateClaims = result.GroupBy(a => a.claim_id).Where(g => g.Count() > 1).Select(y => new { claimID = y.Key, records = y.ToList() });            var newResult = result.GroupBy(a => a.claim_id).Select(g => g.First()).ToList();            foreach (var claim in duplicateClaims)            {                List<byte?> testIds = new List<byte?>();                foreach (var record in claim.records)                {                    testIds.Add(record.claim_validation_test_id[0]);                }                newResult.Where(x => x.claim_id == claim.claimID).ToList().ForEach(y => y.claim_validation_test_id = testIds);            }}Function 2:public HttpResponseMessage GetQuantityValidations()        {            int partitionId = GetPartitionId();            List<ValidationQuantity> = this.db.VW_Validation_Quantity.Where(x => x.partition_id == partitionId).ToList();var duplicateClaims = result.GroupBy(a => a.claim_id).Where(g => g.Count() > 1).Select(y => new { claimID = y.Key, records = y.ToList() });            var newResult = result.GroupBy(a => a.claim_id).Select(g => g.First()).ToList();            foreach (var claim in duplicateClaims)            {                List<byte?> testIds = new List<byte?>();                List<string> testNames = new List<string>();                List<string> resultValues = new List<string>();                foreach (var record in claim.records)                {                    testIds.Add(record.claim_validation_test_id[0]);                    testNames.Add(record.Test[0]);                    resultValues.Add(record.Result[0]);                }                newResult.Where(x => x.claim_id == claim.claimID).ToList().ForEach(y => { y.claim_validation_test_id = testIds; y.Test = testNames; y.Result = resultValues; });}            }Two functions contains same set of code for finding the duplicate records and modification below partvar duplicateClaims = result.GroupBy(a => a.claim_id).Where(g => g.Count() > 1).Select(y => new { claimID = y.Key, records = y.ToList() });            var newResult = result.GroupBy(a => a.claim_id).Select(g => g.First()).ToList();            foreach (var claim in duplicateClaims)            {                ........}how can i simplify above two functions which uses the same set of code for finding the duplicates. need one common function which should behave like generic method accept different model as parameter and implement the same functionalities.
create generic method for two different anonymous types
c#;linq