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
Opens a new Microsoft.Data.SqlClient.SqlConnection
with the given connection string.
Syntax
public static SqlConnection OpenSqlConnection(this ICakeContext context, string connectionString)
Examples
#addin "nuget:?package=Cake.SqlServer"
Task("Sql-Operations")
.Does(() =>
{
using (var connection = OpenSqlConnection(@"Data Source=(localdb)\MSSqlLocalDb;Initial Catalog=MyDatabase"))
{
ExecuteSqlCommand(connection, "...");
ExecuteSqlFile(connection, "./somePath/MyScript.sql");
}
});
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. |
Return Value
Type |
Description |
SqlConnection |
|