C# SSIS 数据流组件 - 创建自定义输入列 [英] C# SSIS Data Flow Component - Creating custom input columns
问题描述
我正在尝试创建我的第一个数据流组件,该组件将使用输入地址通过 PAF api 运行它并从文件源或数据库表中吐出格式正确的地址和原始输入列.
I'm attempting to create my first data flow component that will take an input address run it through a PAF api and spit out the correctly formatted address and the original input columns from a file source or db table.
我需要以特定格式提供源输入地址,因此我需要用户将源输入列映射到特定的自定义输入列.我能够使用 input.ExternalMetadataColumnCollection 创建自定义输入列,这很有效.但是,我现在被告知我现在需要提供将源文件中的所有可用列作为输出列包含在内的选项.
I need to supply the source input address in a particular format, so I need the user to map the source input columns to specific custom input columns. I was able to create custom input columns using the input.ExternalMetadataColumnCollection and this worked. However I have now been told that I need to provide the option of including all available columns in the source file as output columns now.
我已尝试创建显示在列映射"选项卡中的其他输入列,但并非所有源输入列都可用.以下是我迄今为止尝试过的.任何建议将不胜感激.所以我的问题是如何添加额外的自定义输入列以及包括所有源列?
I have tried creating additional input columns which appear in the Column Mapping tab but I don't all all the source input columns available. The below is what I have tried so far. Any advice would be greatly appreciated. So my question is how do I add additional custom input columns as well as including all source columns?
IDTSExternalMetadataColumnCollection100 externalInput = input.ExternalMetadataColumnCollection;
externalInput.IsUsed = true;
IDTSExternalMetadataColumn100 externalInputColumn = externalInput.New();
externalInputColumn.Name = constInputAddressLineOne;
externalInputColumn.DataType = DataType.DT_WSTR;
externalInputColumn = externalInput.New();
externalInputColumn.Name = constInputAddressLineTwo;
externalInputColumn.DataType = DataType.DT_WSTR;
推荐答案
我找到了解决方案.如果你能提出更好的方法,我会全力以赴.我只需要将我的自定义输入列名称设置为只读.我使用了以下内容.
I found a way of doing it. If you can suggest a better way I'm all ears. I just need to set my custom input columns names to read only. I used the following.
public override void OnInputPathAttached(int inputID)
{
IDTSInput100 input = ComponentMetaData.InputCollection[0];
IDTSVirtualInput100 vInput = input.GetVirtualInput();
IDTSExternalMetadataColumnCollection100 externalColumnCollection = input.ExternalMetadataColumnCollection;
IDTSExternalMetadataColumn100 externalColumn;
foreach (IDTSVirtualInputColumn100 vCol in vInput.VirtualInputColumnCollection)
{
externalColumn = externalColumnCollection.New();
externalColumn.Name = vCol.Name;
externalColumn.DataType = vCol.DataType;
}
}
这篇关于C# SSIS 数据流组件 - 创建自定义输入列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!