SqlDefinition.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // System.Data.Sql.SqlDefinition
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2003
  8. //
  9. #if NET_1_2
  10. using System;
  11. namespace System.Data.Sql {
  12. public sealed class SqlDefinition
  13. {
  14. #region Fields
  15. ISqlCommand cmd;
  16. string cmdText;
  17. CommandType cmdType;
  18. SqlMetaData[] metadata;
  19. ParameterDirection[] parmDirection;
  20. #endregion // Fields
  21. #region Constructors
  22. public SqlDefinition (ISqlCommand cmd)
  23. {
  24. this.cmd = cmd;
  25. this.cmdText = cmd.CommandText;
  26. this.cmdType = cmd.CommandType;
  27. }
  28. public SqlDefinition (string cmdText, CommandType cmdType, SqlMetaData[] metadata, ParameterDirection[] parmDirection)
  29. {
  30. this.cmd = null;
  31. this.cmdText = cmdText;
  32. this.cmdType = cmdType;
  33. this.metadata = metadata;
  34. this.parmDirection = parmDirection;
  35. }
  36. #endregion // Constructors
  37. #region Properties
  38. public string CommandText {
  39. get {
  40. if (cmd == null)
  41. return cmdText;
  42. return cmd.CommandText;
  43. }
  44. }
  45. public CommandType CommandType {
  46. get {
  47. if (cmd == null)
  48. return cmdType;
  49. return cmd.CommandType;
  50. }
  51. }
  52. [MonoTODO]
  53. public int ParameterCount {
  54. get {
  55. if (cmd == null)
  56. throw new NotImplementedException ();
  57. return cmd.Parameters.Count;
  58. }
  59. }
  60. #endregion // Properties
  61. #region Methods
  62. public ParameterDirection GetParameterDirection (int i)
  63. {
  64. if (cmd == null)
  65. return parmDirection [i];
  66. return cmd.Parameters [i].Direction;
  67. }
  68. public SqlMetaData GetSqlMetaData (int i)
  69. {
  70. if (cmd == null)
  71. return metadata [i];
  72. return cmd.Parameters [i].MetaData;
  73. }
  74. #endregion // Methods
  75. }
  76. }
  77. #endif