Share via


PropertyRule Class

Defines logic that evaluates to a scalar value for any row in an input table or view. This class cannot be inherited.

Espacio de nombres: Microsoft.SqlServer.NotificationServices.Rules
Ensamblado: Microsoft.SqlServer.NotificationServices.Rules (in microsoft.sqlserver.notificationservices.rules.dll)

Sintaxis

'Declaración
Public Class PropertyRule
    Inherits RuleLogic
public class PropertyRule : RuleLogic
public ref class PropertyRule : public RuleLogic
public class PropertyRule extends RuleLogic
public class PropertyRule extends RuleLogic

Notas

A property rule contains statements in the form "IF Condition THEN Result" where the result is a scalar value determined by evaluating the conditions in the rule.

You must define at least one PropertyStatement using the PropertyStatements property or the PropertyRule(InputType,PropertyStatement[]) constructor. If you define multiple statements, the result of evaluating this rule is the result of the first statement with a matching Condition criteria, or NULL if no criteria is met.

Inheritance Hierarchy

System.Object
   Microsoft.SqlServer.NotificationServices.Rules.RuleObject
     Microsoft.SqlServer.NotificationServices.Rules.StoredRuleObject
       Microsoft.SqlServer.NotificationServices.Rules.RuleLogic
        Microsoft.SqlServer.NotificationServices.Rules.PropertyRule

Ejemplo

The following example shows how to define a property rule that defines three properties: Few, Some, and Alot. It uses this property rule to define a subscription to events where Quantity equals Few:

// Define a new property that defines "Few," "Some," and "Alot"
// of inventory. 
PropertyRule quantityCategory = new PropertyRule(
    new ViewInputType(eventView),
    new PropertyStatement(new SimpleLeafCondition(
        new FieldValue("Quantity"),
        SimpleOperator.LessThan, 100), "Few"),
    new PropertyStatement(new BetweenLeafCondition(
        new FieldValue("Quantity"), 100, 200), "Some"),
    new PropertyStatement(new SimpleLeafCondition(
            new FieldValue("Quantity"),
            SimpleOperator.GreaterThan, 200),
        "Alot"));

// Create subscription and define basic properties.
s = new Subscription(nsApplication, subscriptionClassName);
s.SubscriberId = "Scott";
s.Enabled = true;
s.RuleName = "InventoryTrackerRule";
s.SetFieldValue("DeviceName", "myDevice");
s.SetFieldValue("SubscriberLocale", "en-us");


// Use the new property to return only products with "few" remaining
// in inventory. Note that the category definition can be reused.
s.Condition = new SimpleLeafCondition(
    new RuleValue(quantityCategory),
    SimpleOperator.Equals,
    "Few");

// Add subscription.
s.Add();

Seguridad para subprocesos

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.

Plataformas

Plataformas de desarrollo

Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.

Plataformas de destino

Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.

Vea también

Referencia

PropertyRule Members
Microsoft.SqlServer.NotificationServices.Rules Namespace