SubscriptionClass.SubscriptionFields Property

Gets the collection of fields in the subscription class schema.

Namespace: Microsoft.SqlServer.Management.Nmo
Assembly: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)

Syntax

'Declaration
Public ReadOnly Property SubscriptionFields As SubscriptionFieldCollection
public SubscriptionFieldCollection SubscriptionFields { get; }
public:
property SubscriptionFieldCollection^ SubscriptionFields {
    SubscriptionFieldCollection^ get ();
}
/** @property */
public SubscriptionFieldCollection get_SubscriptionFields ()
public function get SubscriptionFields () : SubscriptionFieldCollection

Property Value

The SubscriptionFieldCollection for the subscription class.

Remarks

For applications in which users can provide subscription parameter values, such as a city name for weather subscriptions, you must specify the subscription fields for storing this data.

Define individual subscription fields using the SubscriptionField class.

Notification Services automatically adds SubscriberID, Created, Updated, and Enabled fields to the subscription class schema.

If you add or delete fields, updating the application re-creates the subscription class to which it corresponds. Notification Services renames the existing subscription tables by appending Old to the table name and then creates new tables. Existing subscription table indexes are left unchanged.

If you want to transfer data between the old and new subscription tables, it must be done manually. For more information, see Updating an Application.

Example

The following examples show how to define and add a subscription field to the end of the collection of fields for a subscription class:

// Define a DeviceName field that cannot be NULL
// Add the field to the end of the field collection
SubscriptionField subDevice = 
    new SubscriptionField(flightSubscriptions, "DeviceName");
subDevice.Type = "nvarchar(255)";
subDevice.TypeModifier = "not null";
flightSubscriptions.SubscriptionFields.Add(subDevice);
' Define a DeviceName field that cannot be NULL
' Add the field to the end of the field collection
Dim subDevice As SubscriptionField = _
    New SubscriptionField(flightSubscriptions, "DeviceName")
subDevice.Type = "nvarchar(255)"
subDevice.TypeModifier = "not null"
flightSubscriptions.SubscriptionFields.Add(subDevice)

The following examples show how to define and add a subscription field at the second position in the collection of fields for a subscription class:

// Add a GoingTo field and add it at position 2
SubscriptionField subDestination = 
    new SubscriptionField(flightSubscriptions, "GoingTo");
subDestination.Type = "nvarchar(6)";
flightSubscriptions.SubscriptionFields.Add(subDestination, 2);
' Add a GoingTo field and add it at position 2
Dim subDestination As SubscriptionField = _
    New SubscriptionField(flightSubscriptions, "GoingTo")
subDestination.Type = "nvarchar(6)"
flightSubscriptions.SubscriptionFields.Add(subDestination, 2)

The following examples show how to define and add a subscription field before the GoingTo field in the subscription class schema:

// Define a LeavingFrom field and add it before the GoingTo field
SubscriptionField subOrgin = 
    new SubscriptionField(flightSubscriptions, "LeavingFrom");
subOrgin.Type = "nvarchar(6)";
flightSubscriptions.SubscriptionFields.Add(subOrgin, "GoingTo");
' Define a LeavingFrom field and add it before the GoingTo field
Dim subOrgin As SubscriptionField = _
    New SubscriptionField(flightSubscriptions, "LeavingFrom")
subOrgin.Type = "nvarchar(6)"
flightSubscriptions.SubscriptionFields.Add(subOrgin, "GoingTo")

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

Target Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

See Also

Reference

SubscriptionClass Class
SubscriptionClass Members
Microsoft.SqlServer.Management.Nmo Namespace
SubscriptionClass.SubscriptionConditionEventRules Property

Other Resources

Defining the Subscription Schema
Schema Element for SubscriptionClass (ADF)