This content is part of a third party extension that is not supported by the Cake project.
For more information about this extension see
Cake.SqlServer.
Summary
Execute any SQL command.
Syntax
public static void ExecuteSqlCommand(this ICakeContext context, string connectionString, string sqlCommands)
Examples
#addin "nuget:?package=Cake.SqlServer"
Task("Sql-Operations")
.Does(() =>
{
var connectionString = @"Data Source=(localdb)\MSSqlLocalDb;Initial Catalog=MyDatabase";
var sqlCommand = "create table [CakeTest].dbo.[CakeTestTable] (id int null)";
ExecuteSqlCommand(connectionString, sqlCommand);
});
Attributes
Type |
Description |
CakeMethodAliasAttribute |
|
Parameters
Name |
Type |
Description |
context |
ICakeContext |
The Cake context. |
connectionString |
string |
The connection string. You may want to specify Initial Catalog. If there are changing parameters, Microsoft.Data.SqlClient.SqlConnectionStringBuilder is recommended to escape input. |
sqlCommands |
string |
SQL to be executed |
Return Value