SqlTriggerAttribute Kelas

Definisi

Digunakan untuk menandai definisi metode dalam rakitan sebagai pemicu dalam SQL Server. Properti pada atribut mencerminkan atribut fisik yang digunakan saat jenis terdaftar dengan SQL Server. Kelas ini tidak dapat diwariskan.

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
Warisan
SqlTriggerAttribute
Atribut

Contoh

Contoh berikut menunjukkan SqlTriggerAttribute penentuan nama pemicu, tabel target, dan peristiwa yang akan mengaktifkan pemicu. Lihat SqlTriggerContext untuk contoh pemicu lengkap.

[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

Keterangan

Lihat "Pemicu CLR" di SQL Server 2005 Books Online untuk informasi selengkapnya tentang pemicu dan contoh CLR.

Konstruktor

SqlTriggerAttribute()

Atribut pada definisi metode dalam rakitan, digunakan untuk menandai metode sebagai pemicu di SQL Server.

Properti

Event

Jenis pemicu dan tindakan bahasa manipulasi data (DML) apa yang mengaktifkan pemicu.

Name

Nama pemicu.

Target

Tabel tempat pemicu berlaku.

Berlaku untuk