Поделиться через


IDTSVirtualInput100.SetUsageType(Int32, DTSUsageType) Метод

Определение

public:
 int SetUsageType(int lLineageID, Microsoft::SqlServer::Dts::Pipeline::Wrapper::Sql2012::DTSUsageType eUsageType);
[System.Runtime.InteropServices.DispId(104)]
public int SetUsageType (int lLineageID, Microsoft.SqlServer.Dts.Pipeline.Wrapper.Sql2012.DTSUsageType eUsageType);
[<System.Runtime.InteropServices.DispId(104)>]
abstract member SetUsageType : int * Microsoft.SqlServer.Dts.Pipeline.Wrapper.Sql2012.DTSUsageType -> int
Public Function SetUsageType (lLineageID As Integer, eUsageType As DTSUsageType) As Integer

Параметры

lLineageID
Int32
eUsageType
DTSUsageType

Возвращаемое значение

Индекс только что созданного IDTSInputColumn100объекта или значение -1, если eUsageType UT_IGNORED и столбец удаляется из коллекции входных столбцов.

Атрибуты

Примеры

В следующем примере кода показана переопределенная реализация компонента , которая использует SetUsageType виртуального SetUsageType ввода для добавления и удаления столбцов из коллекции входных данных. В этом примере компонент не допускает возможность записи столбцов, поэтому при eUsageType UT_READWRITE возникает исключение.

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 следует вызвать метод экземпляра компонента во время разработки. Вызов этого метода напрямую обходит возможность компонента ограничивать столбцы по типу данных или типу использования.

Применяется к