You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Testing.Databases.SqlServer/SqlServer.cs
+28Lines changed: 28 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,21 @@ public SqlServerDatabase CreateEmptyDatabase(string name)
51
51
returnthis.GetDatabase(name);
52
52
}
53
53
54
+
/// <summary>
55
+
/// Creates an empty database asynchronously in the SQL Server instance with the specified <paramref name="name"/>.
56
+
/// If the database already exists, it will be delete.
57
+
/// </summary>
58
+
/// <param name="name">Name of the database to create.</param>
59
+
/// <param name="cancellationToken"><see cref="CancellationToken"/> used to cancel the asynchronous operation.</param>
60
+
/// <returns>A <see cref="Task"/> which represents the asynchronous operation and contains an instance of <see cref="SqlServerDatabase"/> which allows to execute SQL commands/queries.</returns>
awaitthis.Master.ExecuteNonQueryAsync($"IF EXISTS (SELECT 1 FROM [sys].[databases] WHERE [name] = '{name}') ALTER DATABASE [{name}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE",cancellationToken);
90
+
awaitthis.Master.ExecuteNonQueryAsync($"IF EXISTS (SELECT 1 FROM [sys].[databases] WHERE [name] = '{name}') DROP DATABASE [{name}]",cancellationToken);
91
+
}
92
+
65
93
/// <summary>
66
94
/// Gets an instance of the <see cref="SqlServerDatabase"/> for the database specified with the <paramref name="name"/>.
0 commit comments