/Rhino.Etl.Core/ConventionOperations/ConventionInputCommandOperation.cs

http://github.com/ayende/rhino-etl · C# · 73 lines · 38 code · 8 blank · 27 comment · 0 complexity · 2ad7aa60d8db07bc1c08bfe40f466615 MD5 · raw file

  1. using System.Configuration;
  2. namespace Rhino.Etl.Core.ConventionOperations
  3. {
  4. using System.Data;
  5. using Operations;
  6. /// <summary>
  7. /// A convention based version of <see cref="InputCommandOperation"/>. Will
  8. /// figure out as many things as it can on its own.
  9. /// </summary>
  10. public class ConventionInputCommandOperation : InputCommandOperation
  11. {
  12. private string command;
  13. private int timeout;
  14. /// <summary>
  15. /// Gets or sets the command to get the input from the database
  16. /// </summary>
  17. public string Command
  18. {
  19. get { return command; }
  20. set { command = value; }
  21. }
  22. ///<summary>
  23. /// Gets or sets the timeout value for the database command
  24. ///</summary>
  25. public int Timeout
  26. {
  27. get { return timeout; }
  28. set { timeout = value; }
  29. }
  30. /// <summary>
  31. /// Initializes a new instance of the <see cref="ConventionInputCommandOperation"/> class.
  32. /// </summary>
  33. /// <param name="connectionStringName">Name of the connection string.</param>
  34. public ConventionInputCommandOperation(string connectionStringName) : this(ConfigurationManager.ConnectionStrings[connectionStringName])
  35. {
  36. Timeout = 30;
  37. }
  38. /// <summary>
  39. /// Initializes a new instance of the <see cref="ConventionInputCommandOperation"/> class.
  40. /// </summary>
  41. /// <param name="connectionStringSettings">Name of the connection string.</param>
  42. public ConventionInputCommandOperation(ConnectionStringSettings connectionStringSettings)
  43. : base(connectionStringSettings)
  44. {
  45. }
  46. /// <summary>
  47. /// Creates a row from the reader.
  48. /// </summary>
  49. /// <param name="reader">The reader.</param>
  50. /// <returns></returns>
  51. protected override Row CreateRowFromReader(IDataReader reader)
  52. {
  53. return Row.FromReader(reader);
  54. }
  55. /// <summary>
  56. /// Prepares the command for execution, set command text, parameters, etc
  57. /// </summary>
  58. /// <param name="cmd">The command.</param>
  59. protected override void PrepareCommand(IDbCommand cmd)
  60. {
  61. cmd.CommandText = Command;
  62. cmd.CommandTimeout = Timeout;
  63. }
  64. }
  65. }