using System.Collections.Generic;
public static void Main()
List<List<CyberRecord>> cyberSearchRecords = new List<List<CyberRecord>>();
List<CyberRecord> cyberRecords = new List<CyberRecord>();
CyberRecord cyberRecord = new CyberRecord();
cyberRecord.Match = new List<string>{"ssn"};
cyberRecords.Add(cyberRecord);
cyberRecords.Add(cyberRecord);
cyberSearchRecords.Add(cyberRecords);
var outputs = MergeCyberRecordsByCyberIds(cyberSearchRecords);
foreach (var output in outputs)
foreach (var out1 in output)
Console.WriteLine(out1.CyberId);
Console.WriteLine(String.Join(",", out1.Match.Select(x => x).ToArray()));
private static List<List<CyberRecord>> MergeCyberRecordsByCyberIds(List<List<CyberRecord>> cyberSearchRecords)
List<List<CyberRecord>> mergedCyberRecord = new();
List<CyberRecord> cyberRecords = new();
int indexToBeMatched = 1;
CyberRecord record = new();
foreach (var cyberSearchRecord in cyberSearchRecords)
foreach (var cyberRecord in cyberSearchRecord)
if (cyberSearchRecord.Count > indexToBeMatched)
record = cyberSearchRecord[indexToBeMatched];
if (cyberRecord.CyberId == record.CyberId)
List<string> concatenateMatchTypes = new(record.Match.Union(cyberRecord.Match));
record.Match = concatenateMatchTypes;
cyberRecords.Add(record);
mergedCyberRecord.Add(cyberRecords);
return mergedCyberRecord;
public class CyberRecord : CyberRecordMetadata
public ulong CyberId { get; set; }
public string FirstName { get; set; }
public string MiddleInitial { get; set; }
public string LastName { get; set; }
public string StreetAddress1 { get; set; }
public string StreetAddress2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
public string Country { get; set; }
public string Phone { get; set; }
public string Phone1 { get; set; }
public string Phone2 { get; set; }
public string Phone3 { get; set; }
public string PhoneExtension { get; set; }
public string Ssn { get; set; }
public string Last4Ssn { get; set; }
public string NationalId { get; set; }
public string Mmn { get; set; }
public string DateOfBirth { get; set; }
public string DateOfBirthYear { get; set; }
public string DateOfBirthMonth { get; set; }
public string DateOfBirthDay { get; set; }
public string DriverLicenseNumber { get; set; }
public string DriverLicenseState { get; set; }
public string Email { get; set; }
public string EmailDomain { get; set; }
public string UserId { get; set; }
public string Password { get; set; }
public string CardType { get; set; }
public string CardName { get; set; }
public string CardNumber { get; set; }
public string CardBin { get; set; }
public string Md5CardNumber { get; set; }
public string CardCvn { get; set; }
public string CardPin { get; set; }
public string CardExpirationDate { get; set; }
public string CardExpirationYear { get; set; }
public string CardExpirationMonth { get; set; }
public string CardExpirationDay { get; set; }
public string CardAddress { get; set; }
public string RetailCardNumber { get; set; }
public string BankName { get; set; }
public string BankPhone { get; set; }
public string BankRoute { get; set; }
public string BankAccount { get; set; }
public string BankUserId { get; set; }
public string BankPassword { get; set; }
public string BankPin { get; set; }
public string Iban { get; set; }
public string PassportNumber { get; set; }
public DateTimeOffset? PassportExpirationDate { get; set; }
public DateTimeOffset? PassportIssueDate { get; set; }
public string PassportCountry { get; set; }
public string Gender { get; set; }
public string MedicalId { get; set; }
public string MedicalProvider { get; set; }
public string Sha1 { get; set; }
public string Site { get; set; }
public string Source { get; set; }
public DateTimeOffset? SourceDate { get; set; }
public DateTimeOffset? UpdateDate { get; set; }
public DateTimeOffset? CreationDate { get; set; }
public string SourceCategory { get; set; }
public string BreachedSite { get; set; }
public string BreachedSector { get; set; }
public string BreachedSiteCountry { get; set; }
public int BreachedRecordCount { get; set; }
public string CompromiseType { get; set; }
public string PhishedKeyLoggedSite { get; set; }
public string Hacker { get; set; }
public string HackerGroup { get; set; }
public string Motivation { get; set; }
public string HackingOperation { get; set; }
public string PasswordStatus { get; set; }
public string Severity { get; set; }
public string SynopsisId { get; set; }
public class CyberRecordMetadata
public List<string> Match { get; set; }