Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Data / Microsoft / SqlServer / Server / SqlTriggerContext.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="SqlTriggerContext.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 // <owner current="true" primary="true">Microsoft</owner>
6 // <owner current="true" primary="false">Microsoft</owner>
7 // <owner current="true" primary="false">daltodov</owner>
8 //------------------------------------------------------------------------------
9
10 namespace Microsoft.SqlServer.Server {
11
12     using System.Data.Common;
13     using System.Data.SqlClient;
14     using System.Data.SqlTypes;
15     using System.Diagnostics;
16
17     public sealed class SqlTriggerContext {
18
19         TriggerAction   _triggerAction;
20         bool[]          _columnsUpdated;
21         SqlXml          _eventInstanceData;
22
23         internal SqlTriggerContext(TriggerAction triggerAction, bool[] columnsUpdated, SqlXml eventInstanceData) {
24             _triggerAction     = triggerAction;
25             _columnsUpdated    = columnsUpdated;
26             _eventInstanceData = eventInstanceData;
27         }
28
29         public int ColumnCount {
30             get {
31                 int result = 0;
32
33                 if (null != _columnsUpdated) {
34                     result = _columnsUpdated.Length;
35                 }
36                 return result;
37             }
38         }
39
40         public SqlXml EventData {
41             get {
42                 return _eventInstanceData;
43             }
44         }
45
46         public TriggerAction TriggerAction {
47             get {
48                 return _triggerAction;
49             }
50         }
51
52         public bool IsUpdatedColumn(int columnOrdinal) {
53             if (null != _columnsUpdated) {
54                 return _columnsUpdated[columnOrdinal];   // will throw IndexOutOfRangeException if it's out of range...
55             }
56             throw ADP.IndexOutOfRange(columnOrdinal);    // if there aren't any columns, that means IndexOutOfRange too...
57         }
58     }
59 }