SqlServerAliases.

ExecuteSqlCommand(ICakeContext, SqlConnection, string) Method

Summary

Execute any SQL command.
Assembly
Cake.SqlServer.dll
Namespace
Cake.SqlServer
Containing Type
SqlServerAliases

Syntax

public static void ExecuteSqlCommand(this ICakeContext context, SqlConnection connection, string sqlCommands)

Examples

    #addin "nuget:?package=Cake.SqlServer"

    Task("Sql-Operations")
        .Does(() =>
        {
            using (var connection = OpenSqlConnection(@"Data Source=(localdb)\MSSqlLocalDb;Initial Catalog=MyDatabase"))
            {
                ExecuteSqlCommand(connection, "create table [CakeTest].dbo.[CakeTestTable] (id int null)");
                ExecuteSqlCommand(connection, "...");
            }
        });

Attributes

Type Description
CakeMethodAliasAttribute

Parameters

Name Type Description
context ICakeContext The Cake context.
connection SqlConnection The connection to use. The connection must be open. See Cake.SqlServer.SqlServerAliases.OpenSqlConnection(Cake.Core.ICakeContext,System.String).
sqlCommands string SQL to be executed

Return Value

Type Description
void