共用方式為


PropertyStatement Constructor (Condition, Argument)

Initializes a new instance of the PropertyStatement class with a condition and a scalar result.

命名空間: Microsoft.SqlServer.NotificationServices.Rules
組件: Microsoft.SqlServer.NotificationServices.Rules (in microsoft.sqlserver.notificationservices.rules.dll)

語法

'宣告
Public Sub New ( _
    condition As Condition, _
    result As Argument _
)
public PropertyStatement (
    Condition condition,
    Argument result
)
public:
PropertyStatement (
    Condition^ condition, 
    Argument^ result
)
public PropertyStatement (
    Condition condition, 
    Argument result
)
public function PropertyStatement (
    condition : Condition, 
    result : Argument
)

參數

  • condition
    The Condition object that represents the condition to evaluate. This parameter sets the Condition property.
  • result
    The Argument object that represents the scalar result to return if the condition is met. This parameter sets Result property.

備註

You can define a NULL result by setting the result parameter to new ConstantValue(null).

範例

The following example shows how to specify three properties: Few, Some, and Alot. Subscribers can use these properties when defining subscriptions.

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

平台

開發平台

如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。

目標平台

如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。

請參閱

參考

PropertyStatement Class
PropertyStatement Members
Microsoft.SqlServer.NotificationServices.Rules Namespace