Created
September 9, 2015 09:52
-
-
Save fffej/b4a48e86654bf8fef3d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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