SubscriptionConditionEventRuleCollection.Add Method
Adds an SubscriptionConditionEventRule to the SubscriptionConditionEventRuleCollection.
命名空间: Microsoft.SqlServer.Management.Nmo
程序集: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)
语法
声明
Public Sub Add ( _
subscriptionConditionEventRule As SubscriptionConditionEventRule _
)
public void Add (
SubscriptionConditionEventRule subscriptionConditionEventRule
)
public:
void Add (
SubscriptionConditionEventRule^ subscriptionConditionEventRule
)
public void Add (
SubscriptionConditionEventRule subscriptionConditionEventRule
)
public function Add (
subscriptionConditionEventRule : SubscriptionConditionEventRule
)
参数
- subscriptionConditionEventRule
The SubscriptionConditionEventRule to add to the collection.
备注
If you add rules after deploying the application, you must Update the instance to apply the changes.
示例
The following example shows how to define a condition-based, event-driven subscription rule and add it to a subscription class:
// Add a rule to generate condition-based, event notifications
SubscriptionConditionEventRule flightConditionEventRule =
new SubscriptionConditionEventRule(
flightSubscriptions, "FlightConditionEventRule");
flightConditionEventRule.EventClassName = "FlightEvents";
flightConditionEventRule.ActionTimeout = new TimeSpan(0, 2, 0);
flightConditionEventRule.SqlLoginName = "MyLowPrivLogin";
flightConditionEventRule.SqlUserName = "MyLowPrivUser";
flightConditionEventRule.InputTypeName = "FlightEvents";
flightConditionEventRule.InputTypeSchema = "MyAppSchema";
flightConditionEventRule.SqlExpression =
"INSERT INTO MyAppSchema.FlightNotifications (SubscriberId, " +
"DeviceName, SubscriberLocale, LeavingFrom, GoingTo, Price) " +
"SELECT [Subscription.SubscriberId], [Subscription.DeviceName], " +
"[Subscription.SubscriberLocale], " +
"[Input.LeavingFrom], [Input.GoingTo], [Input.Price] " +
"FROM MyAppSchema.FlightConditionEventRule;";
flightSubscriptions.SubscriptionConditionEventRules.Add(
flightConditionEventRule);
' Add a rule to generate condition-based, event notifications
Dim flightConditionEventRule As _
SubscriptionConditionEventRule = _
New SubscriptionConditionEventRule( _
flightSubscriptions, "FlightConditionEventRule")
flightConditionEventRule.EventClassName = "FlightEvents"
flightConditionEventRule.ActionTimeout = New TimeSpan(0, 2, 0)
flightConditionEventRule.SqlLoginName = "MyLowPrivLogin"
flightConditionEventRule.SqlUserName = "MyLowPrivUser"
flightConditionEventRule.InputTypeName = "FlightEvents"
flightConditionEventRule.InputTypeSchema = "MyAppSchema"
flightConditionEventRule.SqlExpression = _
"INSERT INTO MyAppSchema.FlightNotifications " + _
"(SubscriberId, DeviceName, SubscriberLocale, LeavingFrom, " + _
"GoingTo, Price) SELECT [Subscription.SubscriberId], " + _
"[Subscription.DeviceName], [Subscription.SubscriberLocale], " + _
"[Input.LeavingFrom], [Input.GoingTo], [Input.Price] " + _
"FROM MyAppSchema.FlightConditionEventRule;"
flightSubscriptions.SubscriptionConditionEventRules.Add( _
flightConditionEventRule)
线程安全
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.
平台
开发平台
有关支持的平台列表,请参阅安装 SQL Server 2005 的硬件和软件要求。
目标平台
有关支持的平台列表,请参阅安装 SQL Server 2005 的硬件和软件要求。
请参阅
参考
SubscriptionConditionEventRuleCollection Class
SubscriptionConditionEventRuleCollection Members
Microsoft.SqlServer.Management.Nmo Namespace
其他资源
定义事件规则
EventRule Element (ADF)
定义条件操作
ConditionAction Element (ADF)