PageRenderTime 897ms CodeModel.GetById 684ms app.highlight 3ms RepoModel.GetById 209ms app.codeStats 0ms

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