다음을 통해 공유


EventClass Class

Represents a event class for a Notification ServicesApplication.

네임스페이스: Microsoft.SqlServer.Management.Nmo
어셈블리: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)

구문

‘선언
Public NotInheritable Class EventClass
    Inherits NamedSmoObject
public sealed class EventClass : NamedSmoObject
public ref class EventClass sealed : public NamedSmoObject
public final class EventClass extends NamedSmoObject
public final class EventClass extends NamedSmoObject

주의

An event class represents one type of event used by your Notification Services application. When you define your application, you define an event class for every type of event that you maintain in the application database.

If you remove an event class from an application, updating the application deletes the underlying tables and indexes in the application database. Any data existing in the original event class tables is permanently deleted.

You can have 0 to 64 event classes in a single Notification Services application. If you maintain events in external databases and query those databases in your subscription rules, you do not define event classes for these events.

Inheritance Hierarchy

System.Object
   Microsoft.SqlServer.Management.Smo.SmoObjectBase
     Microsoft.SqlServer.Management.Smo.SqlSmoObject
       Microsoft.SqlServer.Management.Smo.NamedSmoObject
        Microsoft.SqlServer.Management.Nmo.EventClass

The following examples show event class definitions using all event class properties and using all methods for adding fields to the event class:

EventClass flightEvents = 
    new EventClass(myApplication, "FlightEvents");

flightEvents.FileGroup = "PRIMARY";

// Add an orgin field to the end of the field collection
EventField eventOrgin = 
    new EventField(flightEvents, "LeavingFrom");
eventOrgin.Type = "nvarchar(6)";
eventOrgin.TypeModifier = "not null";
flightEvents.EventFields.Add(eventOrgin);

// Define a price field and add it at position 1
EventField eventPrice = new EventField(flightEvents, "Price");
eventPrice.Type = "float";
flightEvents.EventFields.Add(eventPrice, 1);

// Define a destination field and add it before the Price field
EventField eventDestination = 
    new EventField(flightEvents, "GoingTo");
eventDestination.Type = "nvarchar(6)";
flightEvents.EventFields.Add(eventDestination, "Price");

// Add the event class to the application
myApplication.EventClasses.Add(flightEvents);

// Add an index to the event class to help improve performance
flightEvents.IndexSqlStatements.Add(
    "CREATE INDEX FlightEventsIndex ON MyAppSchema.FlightEvents " + 
    "( LeavingFrom, GoingTo );");

// Define a chronicle for the class
EventChronicle ec1 = 
    new EventChronicle(flightEvents, "FlightEventChonicle");
ec1.SqlStatements.Add(
    "CREATE TABLE MyAppSchema.FlightEventChronicle " + 
    " (LeavingFrom nvarchar(6), GoingTo nvarchar(6), " +  
    " Price float);");
ec1.SqlStatements.Add(
    "CREATE INDEX FlightEventChronicleIndex  " + 
    "ON MyAppSchema.FlightEventChronicle " + 
    "( LeavingFrom, GoingTo );");
flightEvents.EventChronicles.Add(ec1);

// Define the event chronicle rule
EventChronicleRule ec1Rule = 
    new EventChronicleRule(flightEvents, 
    "FlightEventChronicleRule");
ec1Rule.Action = "INSERT MyAppSchema.FlightEventChronicle " + 
    " (LeavingFrom, GoingTo, Price) " + 
    " SELECT LeavingFrom, GoingTo, Price " + 
    " FROM MyAppSchema.FlightEvents;";
ec1Rule.ActionTimeout = new TimeSpan(0, 1, 20);
flightEvents.EventChronicleRule = ec1Rule;
Dim flightEvents As EventClass = _
    New EventClass(myApplication, "FlightEvents")

flightEvents.FileGroup = "PRIMARY"

' Add an orgin field to the end of the field collection.
Dim eventOrgin As EventField = _
    New EventField(flightEvents, "LeavingFrom")
eventOrgin.Type = "nvarchar(6)"
eventOrgin.TypeModifier = "not null"
flightEvents.EventFields.Add(eventOrgin)

' Define a price field and add it at position 1.
Dim eventPrice As EventField = _
    New EventField(flightEvents, "Price")
eventPrice.Type = "float"
flightEvents.EventFields.Add(eventPrice, 1)

' Define a destination field and add it before the Price field.
Dim eventDestination As EventField = _
    New EventField(flightEvents, "GoingTo")
eventDestination.Type = "nvarchar(6)"
flightEvents.EventFields.Add(eventDestination, "Price")

' Add the event class to the application
myApplication.EventClasses.Add(flightEvents)

' Add an index to the event class to help improve performance.
flightEvents.IndexSqlStatements.Add( _
    "CREATE INDEX FlightEventsIndex " + _
    "ON MyAppSchema.FlightEvents " + _
    "( LeavingFrom, GoingTo );")

' Define a chronicle for the class.
Dim ec1 As EventChronicle = _
    New EventChronicle(flightEvents, "FlightEventChonicle")
ec1.SqlStatements.Add( _
    "CREATE TABLE MyAppSchema.FlightEventChronicle " + _
    " (LeavingFrom nvarchar(6), GoingTo nvarchar(6), " + _
    " Price float);")
ec1.SqlStatements.Add( _
    "CREATE INDEX FlightEventChronicleIndex " + _
    "ON MyAppSchema.FlightEventChronicle " + _
    "( LeavingFrom, GoingTo );")
flightEvents.EventChronicles.Add(ec1)

' Define the event chronicle rule
Dim ec1Rule As EventChronicleRule = _
    New EventChronicleRule(flightEvents, _
        "FlightEventChronicleRule")
ec1Rule.Action = _
    "INSERT MyAppSchema.FlightEventChronicle " + _
    " (LeavingFrom, GoingTo, Price) " + _
    " SELECT LeavingFrom, GoingTo, Price " + _
    " FROM MyAppSchema.FlightEvents;"
ec1Rule.ActionTimeout = New TimeSpan(0, 1, 20)
flightEvents.EventChronicleRule = ec1Rule

스레드 보안

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 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.

참고 항목

참조

EventClass Members
Microsoft.SqlServer.Management.Nmo Namespace

관련 자료

이벤트 클래스 정의
EventClass Element (ADF)