C# Class PiroPiro.DbCleanup.SqlServer.SqlAttach

Restores a SQL database by detaching, overwriting .mdf file and attaching again. (usually faster than a full SQL Restore)
Inheritance: SqlServerStrategy
Show file Open project: benjamine/PiroPiro

Public Methods

Method Description
DetachOverwriteAttach ( string databaseName, string serverName, bool useAsyncCopy = true, string sourceMdfFileSuffix = ".testData", string userName = null, string password = null ) : void

Detachs a database, overwrites its .mdf file, and attachs it again (a faster replacement for a SQL Restore)

PrepareNextCopyAsync ( string filename ) : void
SqlAttach ( Configuration configuration = null ) : System

Protected Methods

Method Description
DoExecute ( ) : void

Private Methods

Method Description
Attach ( string databaseName, string serverName, string userName, string password, string mdfFile ) : void
Detach ( string databaseName, string serverName, string userName = null, string password = null ) : void
GetDatabaseFiles ( string databaseName, string serverName, string &mdfFile, string &logFile, string userName = null, string password = null ) : void
GrantFullControl ( string filename, string user ) : void
LocalPathToUnc ( string serverName, string fullpath ) : string
OverwriteMdfFile ( string serverName, string mdfFile, string logFile, bool useAsyncCopy = true, string sourceMdfFileSuffix = ".testData" ) : void

Method Details

DetachOverwriteAttach() public static method

Detachs a database, overwrites its .mdf file, and attachs it again (a faster replacement for a SQL Restore)
public static DetachOverwriteAttach ( string databaseName, string serverName, bool useAsyncCopy = true, string sourceMdfFileSuffix = ".testData", string userName = null, string password = null ) : void
databaseName string
serverName string
useAsyncCopy bool
sourceMdfFileSuffix string a suffix to add to mdf target filename to obtain the source filename (by default .testData)
userName string
password string
return void

DoExecute() protected method

protected DoExecute ( ) : void
return void

PrepareNextCopyAsync() public static method

public static PrepareNextCopyAsync ( string filename ) : void
filename string
return void

SqlAttach() public method

public SqlAttach ( Configuration configuration = null ) : System
configuration Configuration
return System