public IEnumerable<SqlScript> Filter ( IOrderedEnumerable<SqlScript> sorted, IEnumerable<ExecutedSqlScript> executedScripts, ScriptNameComparer scriptNameComparer, IHasher hasher ) { // check if script has been already executed based on name and hash return sorted.Where(s => !executedScripts.Any(y => scriptNameComparer.Equals(y.Name, s.Name) && (y.Hash == null || y.Hash == hasher.GetHash(s.Contents)))); }
private static bool ScriptIsNewOrChanged( SqlScript sqlScript, ScriptNameComparer comparer, IEnumerable <ExecutedSqlScript> executedScripts, IHasher hasher) => !executedScripts.Any( executedScript => { if (comparer.Equals(executedScript.Name, sqlScript.Name)) { return(executedScript.Hash == null || executedScript.Hash == hasher.GetHash(sqlScript.Contents)); } return(false); });