/// <summary> /// Get the result of executing the specified SQL query /// </summary> /// <param name="conn">Connection to execute the query on</param> /// <param name="sql">SQL query to be performed. If parameters are specified, they will be substituted into the query</param> /// <param name="ct">A <see cref="CancellationToken"/> used to cancel the asynchronous operation</param> /// <returns>A read-only result</returns> public static IPromise <IReadOnlyResult> ApplySql(this IAsyncConnection conn, Command sql, CancellationToken ct) { if (!sql.Aml.TrimStart().StartsWith("<")) { sql.Aml = "<sql>" + ServerContext.XmlEscape(sql.Aml) + "</sql>"; } return(ApplyAsyncInt(conn, sql.WithAction(CommandAction.ApplySQL), ct)); }
/// <summary> /// Get the result of executing the specified SQL query /// </summary> /// <param name="conn">Connection to execute the query on</param> /// <param name="sql">SQL query to be performed. If parameters are specified, they will be substituted into the query</param> /// <param name="parameters">Parameters to be injected into the query</param> /// <returns>A read-only result</returns> public static IReadOnlyResult ApplySql(this IConnection conn, Command sql, params object[] parameters) { var aml = sql.Aml; if (!aml.TrimStart().StartsWith("<")) { aml = "<sql>" + ServerContext.XmlEscape(aml) + "</sql>"; } return(conn.Apply(sql.WithAml(aml, parameters).WithAction(CommandAction.ApplySQL))); }