作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用 EZApi,创建了一个 EzOleDbSource 对象,并分配了 Table 属性。
添加了另一个任务 (EzDerivedColumn) 并附加到 EzOleDbSource 对象。
当我打开包时,我需要点击OLEDB源来获取列输出到派生任务的输入。
有没有办法使用 EzApi 以编程方式设置输入和输出映射?注意:我正在使用 LinkAllInputsToOutputs();
代码:
EzSqlOleDbCM RefConn = new EzSqlOleDbCM(package, dataVault_ConMgr);
EzOleDbSource ezOleDbSource_SatFromStaging = new EzOleDbSource(satelliteDft);
ezOleDbSource_SatFromStaging.Table = formatSQLTableName(settings.bd_datavault_schema_staging, stgTable);
ezOleDbSource_SatFromStaging.Name = settings.ssis_prefix_dataflow_oledb_source + stgTable;
EzDerivedColumn ezDerivedColumn = new EzDerivedColumn(satelliteDft);
ezDerivedColumn.LinkAllInputsToOutputs();
ezDerivedColumn.AttachTo(ezOleDbSource_SatFromStaging);
ezDerivedColumn.Name = settings.ssis_prefix_task_derived + stgTable;
最佳答案
可能不是最好的代码,但这对我有用。它生成一个带有数据流的包,其中包含一个 OLE DB 源,一个仅执行子字符串并写入表的派生列。
我收到一些警告和信息消息,但我认为这是由于没有足够的时间以编程方式处理派生列。
/// <summary>
/// Create a package with a data flow that pulls from table src_dWolf
/// <example>
/// CREATE TABLE dbo.src_dWolf
/// (
/// le_key int NOT NULL PRIMARY KEY
/// , le_value varchar(50) NOT NULL
/// );
///
/// CREATE TABLE dbo.dst_dWolf
/// (
/// le_key int NOT NULL PRIMARY KEY
/// , le_value varchar(50) NOT NULL
/// , le_newValue varchar(20) NOT NULL
/// );
///
/// INSERT INTO dbo.src_dWolf
/// (
/// le_key
/// , le_value
/// )
/// VALUES
/// (
/// 10
/// , 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU'
/// );
/// </example>
/// </summary>
public static void Demo()
{
string dataVault_ConMgr = @"Data Source=localhost\DEV2012;Provider=SQLNCLI10.1;Integrated Security=SSPI;Initial Catalog=TypeMoreClickLess;";
EzPackage package = new EzPackage();
string stgTable = "src_dWolf";
string bd_datavault_schema_staging = "dbo";
string ssis_prefix_dataflow_oledb_source = "SRC ";
string ssis_prefix_task_derived = "DST ";
EzDataFlow satelliteDft = new EzDataFlow(package);
satelliteDft.Name = "DFT demo";
EzSqlOleDbCM RefConn = new EzSqlOleDbCM(package, dataVault_ConMgr);
RefConn.Name = "TMCL";
RefConn.ConnectionString = dataVault_ConMgr;
EzOleDbSource ezOleDbSource_SatFromStaging = new EzOleDbSource(satelliteDft);
ezOleDbSource_SatFromStaging.Table = String.Format("[{0}].[{1}]", bd_datavault_schema_staging, stgTable);
ezOleDbSource_SatFromStaging.Name = ssis_prefix_dataflow_oledb_source + stgTable;
ezOleDbSource_SatFromStaging.Connection = RefConn;
EzDerivedColumn ezDerivedColumn = new EzDerivedColumn(satelliteDft);
ezDerivedColumn.Name = ssis_prefix_task_derived + stgTable;
ezDerivedColumn.InsertOutputColumn("le_newValue");
ezDerivedColumn.SetOutputColumnDataTypeProperties("le_newValue", Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_STR, 20, 0, 0, 1252);
// http://social.msdn.microsoft.com/Forums/sqlserver/en-US/137af5f4-3d35-45c2-9a3f-2127dc98fb6c/ezapi-how-to-working-with-ezderivedcolumn?forum=sqlintegrationservices
Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSOutputColumn100 derCol = ezDerivedColumn.OutputCol("le_newValue");
derCol.CustomPropertyCollection["FriendlyExpression"].Value = "SUBSTRING([le_value], 1, 20 )";
derCol.CustomPropertyCollection["Expression"].Value = "SUBSTRING([le_value], 1, 20 )";
ezDerivedColumn.AttachTo(ezOleDbSource_SatFromStaging);
EzOleDbDestination ezOleDbDestination = new EzOleDbDestination(satelliteDft);
ezOleDbDestination.Name = "DST dst_dWolf";
ezOleDbDestination.Table = "[dbo].[dst_dWolf]";
ezOleDbDestination.Connection = RefConn;
ezOleDbDestination.FastLoadKeepIdentity = true;
ezOleDbDestination.FastLoadKeepNulls = true;
ezOleDbDestination.FastLoadOptions = "TABLOCK,CHECK_CONSTRAINTS";
ezOleDbDestination.AccessMode = AccessMode.AM_OPENROWSET_FASTLOAD;
ezOleDbDestination.AttachTo(ezDerivedColumn);
ezOleDbDestination.LinkAllInputsToOutputs();
package.SaveToFile(@"C:\sandbox\TypeMoreClickLess\EzAPIDemo\dwolf.dtsx");
}
关于c# - 使用带有 OLEDBSource 的 EZApi 自动映射列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19529606/
使用 EZApi,创建了一个 EzOleDbSource 对象,并分配了 Table 属性。 添加了另一个任务 (EzDerivedColumn) 并附加到 EzOleDbSource 对象。 当我打
我是一名优秀的程序员,十分优秀!