Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// I was just browsing the code, and there's a lot of this repetition.
if (!options.AreAllEnabled(Options.IgnoreKeys))
{
foreach (var val in ForeignKeys.CompareWith(target.ForeignKeys, options))
{
yield return val.AddContext(this);
}
}
if (!options.AreAllEnabled(Options.IgnoreChecks))
{
foreach (var val in CheckConstraints.CompareWith(target.CheckConstraints, options))
{
yield return val.AddContext(this);
}
}
// Is there a way to simplify this dramatically?
// Firstly, push the outer most if statement into the inner "CompareWith" so that the options check isn't done there
// Secondly, slap a select to add the context
// Finally, whack it all together with a giant concat statement.
return CheckConstraints.CompareWith(target.CheckConstraints, options).Select(x => x.AddContext(this)).Concat(
ForeignKeys.CompareWith(target.ForeignKeys, options).Select(x => x.AddContext(this));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.