public static void Main()
new Record("foo", "bar", "foobar"),
new Record("foo", null, "foo"),
new Record(null, "bar", "bar"),
new Record(null, null, "DefaultValue"),
var switchCase = dataRecords
.Aggregate<Pattern, Func<string, string, string>>(
(l, r) => pattern.Predicate(l, r) ? pattern.ReturnValue : next(l, r)
Console.WriteLine(switchCase("foo", "bar"));
Console.WriteLine(switchCase("foo", "adfgdafg"));
Console.WriteLine(switchCase("fadgdsfoo", "bar"));
Console.WriteLine(switchCase("asdfadfg", "asfhgsd"));
static Pattern CreatePattern(Record rec)
(l == rec.Input1 || rec.Input1 == null)
&& (r == rec.Input2 || rec.Input2 == null),
public record Pattern(Func<string, string, bool> Predicate, string ReturnValue);
public record Record(string Input1, string Input2, string ReturnValue);