Daeer-Projects / DatabaseOperations

A library of operations that can be applied to an MS SQL Server database.
MIT License
5 stars 2 forks source link

ConnectionOptions should follow the normal pattern for options being passed into a new class #69

Closed Daeer-Projects closed 2 years ago

Daeer-Projects commented 2 years ago

Describe the bug The ConnectionOptions class is created and passed into the operator. The expected pattern to be used is by using a function to set the options from within the consuming class.

Expected behaviour The expected pattern should look like this:

BackupOperator backupOperator = new();

backupOperator.BackupDatabase(options =>
  {
    options.ConnectionString = @"server=MyComputer\SQLDEV;database=TestDatabase;Integrated Security=SSPI;Connect Timeout=5;";
    options.BackupPath = @"E:\Database\Backups\";
  });

Additional context The backup path and the execution timeout have default values, so can be supplied or not as the consuming application chooses.

Breaking Change This pattern will be a breaking change for the library. This pattern is also used mainly for options that have full default values. This library requires the connection string.

Questions As the connection string must be supplied, should this pattern be implemented?

Daeer-Projects commented 2 years ago

I think I also need to split out the connection string options from the backup path options. The execution timeout will be required for backup and restore operators.

Daeer-Projects commented 2 years ago

I have taken this idea from the excellent Nick Chapsas.

See his YouTube video at the link: https://www.youtube.com/watch?v=kIkbGXLkc-g

Daeer-Projects commented 2 years ago

Changes made. Wiki and ReadMe to do still before closing this issue.

Daeer-Projects commented 2 years ago

I'm going to update the readme to use a more friendly welcome to other contributors.

Daeer-Projects commented 2 years ago

I've updated the wiki now, so this can be closed.