PageRenderTime 384ms CodeModel.GetById 192ms app.highlight 11ms RepoModel.GetById 171ms app.codeStats 1ms

/Rhino.Etl.Core/ConventionOperations/ConventionSqlBulkInsertOperation.cs

http://github.com/ayende/rhino-etl
C# | 65 lines | 35 code | 7 blank | 23 comment | 0 complexity | 3bd6b4963497cb08939f29d97ef31b2b MD5 | raw file
 1using System;
 2using System.Configuration;
 3using Rhino.Etl.Core.Operations;
 4
 5namespace Rhino.Etl.Core.ConventionOperations
 6{
 7    /// <summary>Convertion wrapper around the <see cref="SqlBulkInsertOperation"/>.</summary>
 8    public class ConventionSqlBulkInsertOperation : SqlBulkInsertOperation
 9    {
10        /// <summary>Creates a new <see cref="ConventionSqlBulkInsertOperation"/></summary>
11        /// <param name="connectionStringName"></param>
12        /// <param name="targetTable"></param>
13        public ConventionSqlBulkInsertOperation(string connectionStringName, string targetTable) : this(ConfigurationManager.ConnectionStrings[connectionStringName], targetTable)
14        {
15        }
16
17        /// <summary>Creates a new <see cref="ConventionSqlBulkInsertOperation"/></summary>
18        /// <param name="connectionStringSettings">Connection string settings to use.</param>
19        /// <param name="targetTable"></param>
20        public ConventionSqlBulkInsertOperation(ConnectionStringSettings connectionStringSettings, string targetTable)
21            : base(connectionStringSettings, targetTable)
22        {
23        }
24
25        /// <summary>
26        /// Prepares the schema of the target table
27        /// </summary>
28        protected override void PrepareSchema()
29        {
30        }
31
32        /// <summary>
33        /// Prepares the mapping for use, by default, it uses the schema mapping.
34        /// This is the preferred appraoch
35        /// </summary>
36        public override void PrepareMapping()
37        {
38        }
39
40        /// <summary>Adds a column to the destination mapping.</summary>
41        /// <param name="destinationColumn">The name of column, this is case sensitive.</param>
42        public virtual void MapColumn(string destinationColumn)
43        {
44            MapColumn(destinationColumn, typeof (string));
45        }
46
47        /// <summary>Adds a column and specified type to the destination mapping.</summary>
48        /// <param name="destinationColumn">The name of the column</param>
49        /// <param name="columnType">The type of the column.</param>
50        public virtual void MapColumn(string destinationColumn, Type columnType)
51        {
52            MapColumn(destinationColumn, destinationColumn, columnType);
53        }
54
55        /// <summary>Adds a column and the specified type to the destination mapping with the given sourceColumn mapping.</summary>
56        /// <param name="destinationColumn"></param>
57        /// <param name="columnType"></param>
58        /// <param name="sourceColumn"></param>
59        public virtual void MapColumn(string destinationColumn, string sourceColumn, Type columnType)
60        {
61            Schema[destinationColumn] = columnType;
62            Mappings[sourceColumn] = destinationColumn;
63        }
64    }
65}