public/Add-GzDbProviderFactory.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


function Add-GzDbProviderFactory() {
<#
.SYNOPSIS
    Add a db provider factory.
.DESCRIPTION
    Add a db provider factory by name and factory instance.
.EXAMPLE
    PS C:\> Add-GzDbProviderFactory -Name "MySql" -Factory [MySQL.Data.MySQLClient.MySqlClientFactory]::Instance
     
.INPUTS
    Inputs (if any)
.OUTPUTS
    None
.NOTES
    General notes
#>

    Param(
        [Parameter(Position = 0, Mandatory = $true)]
        [String] $Name,

        [Parameter(Position = 1, Mandatory = $true, ValueFromPipeline = $true)]
        [System.Data.Common.DbProviderFactory] $Factory,

        [Switch] $Default 
    )

    Set-GzDbOption -Name "DbProviderFactories/$Name" -Value $Factory

    if($Default.ToBool()) {
        Set-GzDbOption -Name "DbProviderFactories/Default" -Value $Factory
    }
}