SubscriptionEventRule Class
Represents an event rule that contains simple actions, not condition actions.
命名空间: Microsoft.SqlServer.Management.Nmo
程序集: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)
语法
声明
Public NotInheritable Class SubscriptionEventRule
Inherits NamedSmoObject
public sealed class SubscriptionEventRule : NamedSmoObject
public ref class SubscriptionEventRule sealed : public NamedSmoObject
public final class SubscriptionEventRule extends NamedSmoObject
public final class SubscriptionEventRule extends NamedSmoObject
备注
The SubscriptionEventRule class represents a rule that uses simple parameter-based Transact-SQL queries to generate notifications as event batches arrive, or that do other processing, such as maintaining chronicles.
Each SubscriptionEventRule object must specify an action, which is a Transact-SQL query that does the work of the rule. A subscription class can have multiple SubscriptionEventRule objects, and can also have SubscriptionConditionEventRule, SubscriptionScheduledRule, and SubscriptionConditionScheduledRule objects.
SubscriptionEventRule objects are associated with a subscription class through the SubscriptionEventRules property.
Inheritance Hierarchy
System.Object
Microsoft.SqlServer.Management.Smo.SmoObjectBase
Microsoft.SqlServer.Management.Smo.SqlSmoObject
Microsoft.SqlServer.Management.Smo.NamedSmoObject
Microsoft.SqlServer.Management.Nmo.SubscriptionEventRule
示例
The following examples show how to define an event rule and then add it to a subscription class:
// Add a rule to generate basic event-triggered notifications
SubscriptionEventRule flightEventRule =
new SubscriptionEventRule(flightSubscriptions,
"FlightSubscriptionsEventRule");
flightEventRule.Action = "INSERT INTO FlightNotifications " +
"(SubscriberId, DeviceName, SubscriberLocale, " +
"LeavingFrom, GoingTo, Price) " +
"SELECT S.SubscriberId, S.DeviceName, S.SubscriberLocale, " +
"E.LeavingFrom, E.GoingTo, E.Price " +
"FROM FlightEvents E, FlightSubscriptions S " +
"WHERE E.LeavingFrom = S.LeavingFrom " +
"AND E.GoingTo = S.GoingTo " +
"AND E.Price < S.Price";
flightEventRule.ActionTimeout = new TimeSpan(0, 1, 0);
flightEventRule.EventClassName = "FlightEvents";
flightSubscriptions.SubscriptionEventRules.Add(flightEventRule);
' Add a rule to generate basic event-triggered notifications
Dim flightEventRule As SubscriptionEventRule = _
New SubscriptionEventRule(flightSubscriptions, _
"FlightSubscriptionsEventRule")
flightEventRule.Action = _
"INSERT INTO FlightNotifications " + _
"(SubscriberId, DeviceName, SubscriberLocale, " + _
"LeavingFrom, GoingTo, Price) " + _
"SELECT S.SubscriberId, S.DeviceName, S.SubscriberLocale, " + _
"E.LeavingFrom, E.GoingTo, E.Price " + _
"FROM FlightEvents E, FlightSubscriptions S " + _
"WHERE E.LeavingFrom = S.LeavingFrom " + _
"AND E.GoingTo = S.GoingTo " + _
"AND E.Price < S.Price"
flightEventRule.ActionTimeout = New TimeSpan(0, 1, 0)
flightEventRule.EventClassName = "FlightEvents"
flightSubscriptions.SubscriptionEventRules.Add(flightEventRule)
线程安全
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 的硬件和软件要求。
请参阅
参考
SubscriptionEventRule Members
Microsoft.SqlServer.Management.Nmo Namespace
其他资源
定义事件规则
Action Element for EventRule (ADF)
EventRule Element (ADF)