SqlServerAliases.

SetSqlCommandTimeout(ICakeContext, int) Method

Summary

Sets the CommandTimeout property for all SqlCommands used internally
Assembly
Cake.SqlServer.dll
Namespace
Cake.SqlServer
Containing Type
SqlServerAliases

Syntax

public static void SetSqlCommandTimeout(this ICakeContext context, int commandTimeout)

Examples

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

     Task("Sql-Operations")
         .Does(() =>
         {
             SetSqlCommandTimeout(60);
             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.
commandTimeout int The time in seconds to wait for the command to execute. Used to set CommandTimeout property to when creating Microsoft.Data.SqlClient.SqlCommand

Return Value

Type Description
void