/// <summary> /// Returns the final query to be executed, including the additional statements /// </summary> /// <param name="query">The current query</param> /// <returns>A query containing the pre and post statements</returns> public string GetFinalStatement(string query) { // Append the Before and After statements if (BeforeQueryStatements.Count > 0) { query = String.Join($"{StatementEndCharacter}\r\n", BeforeQueryStatements.ToArray()) + "\r\n" + query; } if (AfterQueryStatements.Count > 0) { query = "\r\n" + query + String.Join($"{StatementEndCharacter}\r\n", AfterQueryStatements.ToArray()); } return(query); }
/// <summary> /// Format the statement accordingly to the the dialect. /// </summary> /// <param name="statement">The statement to format</param> /// <remarks> /// Formatting will append the queries on the <see cref="BeforeQueryStatements"/> and <see cref="AfterQueryStatements"/> to the query, and append the <see cref="StatementEndCharacter"/> to the end of each sentence. /// It will not format any data inside it. Use <see cref="FormatTable(Table)"/> to Format the tables inside the statement. /// </remarks> /// <returns></returns> public virtual string FormatStatement(string statement) { // Variable to hold the results string resultStatement = $"{statement}{StatementEndCharacter}\r\n";; // Add Before Query Statements if (BeforeQueryStatements?.Count > 0) { resultStatement = String.Join(StatementEndCharacter + "\r\n", BeforeQueryStatements.ToArray()) + resultStatement; } // Add After Query Statements if (AfterQueryStatements?.Count > 0) { resultStatement += String.Join(StatementEndCharacter + "\r\n", AfterQueryStatements.ToArray()); } // Finally return the statement return(resultStatement); }