Partager via


Subscription.Condition Property

Gets or sets the condition. This property is used for subscription classes that contain condition actions.

Espace de noms: Microsoft.SqlServer.NotificationServices
Assembly: Microsoft.SqlServer.NotificationServices (in microsoft.sqlserver.notificationservices.dll)

Syntaxe

'Déclaration
Public Property Condition As Condition
public Condition Condition { get; set; }
public:
property Condition^ Condition {
    Condition^ get ();
    void set (Condition^ value);
}
/** @property */
public Condition get_Condition ()

/** @property */
public void set_Condition (Condition value)
public function get Condition () : Condition

public function set Condition (value : Condition)

Valeur de propriété

A Microsoft.SqlServer.NotificationServices.Rules.Condition object that specifies the conditions for the subscription.

Notes

ms149138.note(fr-fr,SQL.90).gifRemarque :
This method does not support COM interop.

In SQL Server 2000 Notification Services, subscribers created subscriptions by defining parameter values for pre-defined queries. In SQL Server 2005 Notification Services, your subscription classes can have condition actions, which allow subscribers to define more complex conditions.

A single subscription class can support parameter-based actions and condition actions. Subscriptions that use condition actions must have both of the Condition and RuleName properties. Subscriptions that do not use condition actions must have neither of these properties.

For more information about conditions, see Définition des actions de condition.

The subscription management interface must have VIEW DEFINITION permissions on the objects referenced in the condition. The objects typically are the Input tables and views and any user-defined functions used by the conditions. For example, if your subscription management interface runs under NSTestUser, you can grant permissions on the Sales.Customer view and then dbo.ufnGetAccountEndDate user-defined function using the following Transact-SQL statements:

GRANT VIEW DEFINITION ON Sales.Customer TO NSTestUser;
GRANT VIEW DEFINITION ON dbo.ufnGetAccountingEndDate TO NSTestUser;

Exemple

The following example shows how to define a condition for a subscription.

' Create the NSInstance object.
Dim testInstance As New NSInstance("InventoryTrackerInstance")
 
' Create the NSApplication object.
Dim testApplication As _
    New NSApplication(testInstance, "InventoryTracker")
 
' Define subscription properties
Dim s As New Subscription( _
    testApplication, "InventoryTrackerSubscriptions")
s.SubscriberId = "TestUser1"
s.Enabled = True
s.RuleName = "InventoryTrackerRule"
s("DeviceName") = "Work e-mail"
s("SubscriberLocale") = "en-US"
 
' Define OrCondition
s.Condition = New OrCondition( _
    New SimpleLeafCondition( _
        New FieldValue("Quantity"), _
        SimpleOperator.GreaterThanOrEqualTo, _
        500), _
    New SimpleLeafCondition( _
        New FieldValue("Quantity"), _
        SimpleOperator.LessThanOrEqualTo, _
        35))
 
' Add subscription
s.Add()
// Create the NSInstance object.
NSInstance testInstance =
    new NSInstance("InventoryTrackerInstance");

// Create the NSApplication object.
NSApplication testApplication =
    new NSApplication(testInstance, "InventoryTracker");

// Define subscription properties
Subscription s = new Subscription(testApplication, "InventoryTrackerSubscriptions");
s.SubscriberId = "TestUser1";
s.Enabled = true;
s.RuleName = "InventoryTrackerRule";
s["DeviceName"] = "Work e-mail";
s["SubscriberLocale"] = "en-US";

// Define OrCondition
s.Condition = new OrCondition(
    new SimpleLeafCondition(new FieldValue("Quantity"),
        SimpleOperator.GreaterThanOrEqualTo,
        500),
    new SimpleLeafCondition(new FieldValue("Quantity"),
        SimpleOperator.LessThanOrEqualTo,
        35)
);

// Add subscription
s.Add();

Sécurité des threads

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.

Plateformes

Plateformes de développement

Pour obtenir la liste des plateformes prises en charge, consultez Configuration matérielle et logicielle requise pour l'installation de SQL Server 2005.

Plateformes cibles

Pour obtenir la liste des plateformes prises en charge, consultez Configuration matérielle et logicielle requise pour l'installation de SQL Server 2005.

Voir aussi

Référence

Subscription Class
Subscription Members
Microsoft.SqlServer.NotificationServices Namespace

Autres ressources

Autorisation VIEW DEFINITION