using System.Collections.Generic;
public static void Main()
var scripts = new List<Script>()
new Script { Database = "master", File = "sql_master" },
new Script { Database = "myDB", File = "sql_sameGroup1" },
new Script { Database = "myDB", File = "sql_sameGroup2" },
new Script { Database = "myDB", File = "sql_sameGroup3" },
new Script { Database = "myDB", File = "sql_special" },
var grouped = scripts.GroupBy(script => new { script.Database, IsSqlSpecial = script.File is "sql_special" });
foreach (var group in grouped)
Console.WriteLine(group.Key);
foreach (var entry in group)
Console.WriteLine($"{entry.Database} {entry.File}");
public string Database{get;set;}
public string File{get;set;}