SqlTriggerAttribute 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
用于将程序集中的方法定义标记为 SQL Server 中的触发器。 该特性的属性反映了向 SQL Server 注册该类型时所使用的实体特性。 此类不能被继承。
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
		- 继承
 - 
				SqlTriggerAttribute
 
- 属性
 
示例
下面的示例演示 SqlTriggerAttribute 指定触发器的名称、目标表以及将触发触发器的事件。 有关完整的触发器示例,请参阅 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
	注解
有关 CLR 触发器和示例的详细信息,请参阅 SQL Server 2005 联机丛书中的“CLR 触发器”。
构造函数
| SqlTriggerAttribute() | 
		 程序集中的方法定义的特性,用于将方法标记为 SQL Server 中的触发器。  | 
        	
属性
| Event | 
		 触发器的类型和激活触发器的数据操作语言 (DML) 操作。  | 
        	
| Name | 
		 触发器的名称。  | 
        	
| Target | 
		 应用触发器的表。  |