SqlTriggerContext.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. namespace Microsoft.SqlServer.Server {
  10. using System.Data.Common;
  11. using System.Data.SqlClient;
  12. using System.Data.SqlTypes;
  13. using System.Diagnostics;
  14. public sealed class SqlTriggerContext {
  15. TriggerAction _triggerAction;
  16. bool[] _columnsUpdated;
  17. SqlXml _eventInstanceData;
  18. internal SqlTriggerContext(TriggerAction triggerAction, bool[] columnsUpdated, SqlXml eventInstanceData) {
  19. _triggerAction = triggerAction;
  20. _columnsUpdated = columnsUpdated;
  21. _eventInstanceData = eventInstanceData;
  22. }
  23. public int ColumnCount {
  24. get {
  25. int result = 0;
  26. if (null != _columnsUpdated) {
  27. result = _columnsUpdated.Length;
  28. }
  29. return result;
  30. }
  31. }
  32. public SqlXml EventData {
  33. get {
  34. return _eventInstanceData;
  35. }
  36. }
  37. public TriggerAction TriggerAction {
  38. get {
  39. return _triggerAction;
  40. }
  41. }
  42. public bool IsUpdatedColumn(int columnOrdinal) {
  43. if (null != _columnsUpdated) {
  44. return _columnsUpdated[columnOrdinal]; // will throw IndexOutOfRangeException if it's out of range...
  45. }
  46. throw ADP.IndexOutOfRange(columnOrdinal); // if there aren't any columns, that means IndexOutOfRange too...
  47. }
  48. }
  49. }