EventClass Class
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

EventClass Class

Represents a event class for a Notification ServicesApplication.

Namespace: Microsoft.SqlServer.Management.Nmo
Assembly: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)

public sealed class EventClass : 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.

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";

// 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

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

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

// Define the event chronicle rule
EventChronicleRule ec1Rule = 
    new EventChronicleRule(flightEvents, 
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.

Development Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

Target Platforms

© 2016 Microsoft