SqlTriggerAttribute Třída

Definice

Slouží k označení definice metody v sestavení jako triggeru v SQL Server. Vlastnosti atributu odrážejí fyzické atributy použité při registraci typu v SQL Server. Tato třída se nemůže dědit.

public ref class SqlTriggerAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)]
[System.Serializable]
public sealed class SqlTriggerAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)>]
[<System.Serializable>]
type SqlTriggerAttribute = class
    inherit Attribute
Public NotInheritable Class SqlTriggerAttribute
Inherits Attribute
Dědičnost
SqlTriggerAttribute
Atributy

Příklady

Následující příklad ukazuje SqlTriggerAttribute zadání názvu triggeru, cílové tabulky a události, která trigger aktivuje. Úplný příklad triggeru najdete v tématu SqlTriggerContext .

[SqlTrigger(Name = @"SalesAudit", Target = "[dbo].[SalesInfo]", Event = "FOR INSERT")]
public static void SalesAudit()
{
   // Get the trigger context.
   SqlTriggerContext triggContext = SqlContext.TriggerContext;

   switch (triggContext.TriggerAction)
   {
      case TriggerAction.Insert:

      // Do something in response to the INSERT.

      break;
   }
}
<SqlTrigger(Name:="SalesAudit", Target:="[dbo].[SalesInfo]", Event:="FOR INSERT")> _
Public Shared Sub SalesAudit()
        
   Dim triggContext As SqlTriggerContext
         
   ' Get the trigger context.
   triggContext = SqlContext.TriggerContext        

   Select Case triggContext.TriggerAction
      Case TriggerAction.Insert
      
      ' Do something in response to the INSERT.
         
   End Select

End Sub

Poznámky

Další informace o triggerech a příkladech modulu CLR najdete v tématu Triggery CLR v SQL Server 2005 Books Online.

Konstruktory

SqlTriggerAttribute()

Atribut definice metody v sestavení, který slouží k označení metody jako triggeru v SQL Server.

Vlastnosti

Event

Typ triggeru a akce jazyka DML (Data Manipulation Language) trigger aktivuje.

Name

Název triggeru.

Target

Tabulka, na kterou se aktivační událost vztahuje.

Platí pro