IDTSVirtualInput100.SetUsageType(Int32, DTSUsageType) 方法   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
映射虚拟输入列对象并设置其用法类型。
public:
 int SetUsageType(int lLineageID, Microsoft::SqlServer::Dts::Pipeline::Wrapper::DTSUsageType eUsageType);[System.Runtime.InteropServices.DispId(104)]
public int SetUsageType (int lLineageID, Microsoft.SqlServer.Dts.Pipeline.Wrapper.DTSUsageType eUsageType);[<System.Runtime.InteropServices.DispId(104)>]
abstract member SetUsageType : int * Microsoft.SqlServer.Dts.Pipeline.Wrapper.DTSUsageType -> intPublic Function SetUsageType (lLineageID As Integer, eUsageType As DTSUsageType) As Integer参数
- lLineageID
- Int32
要映射的 LineageID 的 IDTSVirtualInputColumn100。
- eUsageType
- DTSUsageType
一个来自 DTSUsageType 枚举的值,该值指示组件如何使用输入列。
返回
新创建的 IDTSInputColumn100 的索引,或者如果 eUsageType 为 UT_IGNORED 时则返回 -1,并且从输入列集合中删除该列。
- 属性
示例
下面的代码示例演示组件的重写实现,该实现 SetUsageType 使用虚拟输入的 SetUsageType 来添加和删除输入集合中的列。 在此示例中,组件不允许列可写,因此当 发生UT_READWRITE异常时eUsageType。
public override IDTSInputColumn100 SetUsageType(int inputID, IDTSVirtualInput100 virtualInput, int lineageID, DTSUsageType usageType)  
{  
    // Prevent use of read/write columns.  
    if (usageType == DTSUsageType.UT_READWRITE)  
        throw new Exception("Read write columns prohibited.");  
    // Get the input specified by inputID.  
    IDTSInput100 input = ComponentMetaData.InputCollection.GetObjectByID(inputID);  
    int index = virtualInput.SetUsageType(lineageID, usageType);  
    // If the index is not -1, return the column.  
    // NOTE: The index that is returned is 1-based, but the input column collection is 0-based.  
    if ( index != -1 )  
        return input.InputColumnCollection[index-1];  
    // The column was removed, so return null.  
    return null;  
}  
Public Overrides Function SetUsageType(ByVal inputID As Integer, ByVal virtualInput As IDTSVirtualInput100, ByVal lineageID As Integer, ByVal usageType As DTSUsageType) As IDTSInputColumn100   
 If usageType = DTSUsageType.UT_READWRITE Then   
   Throw New Exception("Read write columns prohibited.")   
 End If   
 Dim input As IDTSInput100 = ComponentMetaData.InputCollection.GetObjectByID(inputID)   
 Dim index As Integer = virtualInput.SetUsageType(lineageID, usageType)   
 If Not (index = -1) Then   
   Return input.InputColumnCollection(index - 1)   
 End If   
 Return Nothing   
End Function  
注解
自定义组件开发人员通常在其重写的基类 SetUsageType 方法实现中调用此方法,以在组件的输入列集合中添加或删除列。 如果 eUsageType 为 UT_IGNORED,并且该列以前已添加到组件的输入列集合中,则删除列索引。 如果 eUsageType 为 UT_READONLY、 或 UT_READWRITE,则会将列添加到集合中。
以编程方式创建数据流任务并为任务中的组件选择列的开发人员不应调用此方法。 相反, SetUsageType 应调用组件的设计时实例的 方法。 调用此方法直接绕过组件按数据类型或用法类型限制列的功能。