using System.Collections.Generic;
public static void Main()
var logs = new List<AuditLogDto>
new AuditLogFilterablePropertyDto { Name = "Brand", Value = "brand 1" },
new AuditLogFilterablePropertyDto { Name = "Owner", Value = "owner 1" }
new AuditLogFilterablePropertyDto { Name = "Brand", Value = "brand 1" },
new AuditLogFilterablePropertyDto { Name = "Owner", Value = "owner 2" }
new AuditLogFilterablePropertyDto { Name = "Brand", Value = "brand 2" }
new AuditLogFilterablePropertyDto { Name = "Brand", Value = "brand 3" }
var allFilterableProperties = logs
.SelectMany(l => l.FilterableProperties.Select(fp => new { Log = l, FilterableProperty = fp }));
var logsWithOnlyChanges = allFilterableProperties
.GroupBy(x => x.FilterableProperty.Value)
.Select(x => x.First().Log)
Console.WriteLine("Debugging allFilterableProperties...");
Console.WriteLine(JsonSerializer.Serialize(allFilterableProperties, new JsonSerializerOptions { WriteIndented = true }));
Console.WriteLine("These are the logs with only property value changed:");
Console.WriteLine(JsonSerializer.Serialize(logsWithOnlyChanges, new JsonSerializerOptions { WriteIndented = true }));
public record AuditLogFilterablePropertyDto
public required string Name { get; init; }
public required string Value { get; init; }
public record AuditLogDto
public required string Id { get; init; }
public IEnumerable<AuditLogFilterablePropertyDto> FilterableProperties { get; init; } = [];