Поделиться через


Свойство AffinityType

Gets or Sets the AffinityType()()()() member of the AffinityInfo class. Valid values are Auto or Manual.

Пространство имен:  Microsoft.SqlServer.Management.Smo
Сборка:  Microsoft.SqlServer.Smo (в Microsoft.SqlServer.Smo.dll)

Синтаксис

'Декларация
Public Property AffinityType As AffinityType
    Get
    Set
'Применение
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)

Значение свойства

Тип: Microsoft.SqlServer.Management.Smo. . :: . .AffinityType
The current value of the AffinityType()()()() member.

Замечания

Changes are not applied to the Instance of SQL Server until Alter or Server()()()() method is called.

To set any AffinityInfo object properties and run the Alter method, users must have ALTER permission on the database.

Примеры

This example shows you how to display the local instance of SQL Server's AffinityType()()()() setting and then change that setting to the Auto Affinity type.

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()