Udostępnij za pośrednictwem


Właściwość AffinityType

Pobiera lub ustawia AffinityType()()()() element członkowski AffinityInfo klasy Prawidłowe wartości to Auto lub Manual.

Przestrzeń nazw:  Microsoft.SqlServer.Management.Smo
Zestaw:  Microsoft.SqlServer.Smo (w Microsoft.SqlServer.Smo.dll)

Syntax

'Deklaracja
Public Property AffinityType As AffinityType
    Get
    Set
'Użycie
Dim instance As AffinityInfo
Dim value As AffinityType

value = instance.AffinityType

instance.AffinityType = value
public AffinityType AffinityType { get; set; }
public:
property AffinityType AffinityType {
    AffinityType get ();
    void set (AffinityType value);
}
member AffinityType : AffinityType with get, set
function get AffinityType () : AffinityType
function set AffinityType (value : AffinityType)

Wartość właściwości

Typ: Microsoft.SqlServer.Management.Smo. . :: . .AffinityType
Bieżąca wartość AffinityType()()()() element członkowski.

Uwagi

Zmiany nie są stosowane do wystąpienia programu SQL Server dopóki Alter lub Server()()()() wywoływana jest metoda.

Aby zestaw wszelkie AffinityInfo Właściwości obiektu i uruchom Alter Metoda, użytkownicy muszą mieć uprawnienia do zmiany w bazie danych.

Przykłady

W tym przykładzie przedstawiono sposób wyświetlania lokalne wystąpienie programu SQL Server AffinityType()()()() ustawienie, a następnie zmień ustawienie typu Auto koligacji.

using System;
using Microsoft.SqlServer.Management.Smo;

namespace samples
{
    class Program
    {
        static void Main(string[] args)
        {
            Server dbServer = new Server("(local)");

            //Retrieve the servers AffinityInfo settings and
            //display the current AffinityType setting.
            dbServer.Refresh();
            Console.WriteLine(dbServer.AffinityInfo.AffinityType);

            //Change the AffinityType setting to Auto and
            //update the server with the new setting.
            dbServer.AffinityInfo.AffinityType = AffinityType.Auto;
            dbServer.AffinityInfo.Alter();
        }
    }
}

PowerShell

#Create the server. 
$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")

#Retrieve the servers AffinityInfo settings and
#display the current AffinityType setting.
$dbServer.Refresh()
Write-Host $dbServer.AffinityInfo.AffinityType

#Change the AffinityType setting to Auto and
#update the server with the new setting.
$dbServer.AffinityInfo.AffinityType =  [Microsoft.SqlServer.Management.Smo.AffinityType]'Auto'
$dbServer.AffinityInfo.Alter()