public virtual void StoreExecutedScript(SqlScript script, Func <IDbCommand> db) { var name = NameWithHash.FromScript(script); db.Execute(GetDeleteScriptSql(), new { scriptName = name.PlainName }); db.Execute(GetInsertScriptSql(), new { scriptName = name.PlainName, contentsHash = name.ContentsHash }); }
/// <summary> /// Attempts to split the supplied string into name and hash parts. /// The parse will only succeed if the string contains a #. /// </summary> /// <returns><c>true</c>, if parse was successful, <c>false</c> otherwise.</returns> /// <param name="combinedName">Combined name or other string.</param> /// <param name="result">Parsed result.</param> public static bool TryParse(string combinedName, out NameWithHash result) { var pos = combinedName.IndexOf('#'); if (pos == -1) { result = null; return(false); } result = new NameWithHash( combinedName.Substring(0, pos), combinedName.Substring(pos + 1)); return(true); }
/// <summary> /// Given a set of scripts, returns new scripts with the same contents but /// names that are suitably suffixed with the script's hashed contents. This /// makes them compatible with <see cref="SqlHashingJournal"/>. /// </summary> /// <returns>The names.</returns> /// <param name="scripts">Scripts.</param> public static IEnumerable <SqlScript> HashNames(this IEnumerable <SqlScript> scripts) { return(scripts.Select(s => new SqlScript(NameWithHash.FromScript(s).ToString(), s.Contents))); }