ForEachLoop.ForEachEnumerator プロパティ

ForEachEnumerator のホストを取得します。値の設定も可能です。

名前空間:  Microsoft.SqlServer.Dts.Runtime
アセンブリ:  Microsoft.SqlServer.ManagedDTS (Microsoft.SqlServer.ManagedDTS.dll)

構文

'宣言
Public Property ForEachEnumerator As ForEachEnumeratorHost 
    Get 
    Set
'使用
Dim instance As ForEachLoop 
Dim value As ForEachEnumeratorHost 

value = instance.ForEachEnumerator

instance.ForEachEnumerator = value
public ForEachEnumeratorHost ForEachEnumerator { get; set; }
public:
property ForEachEnumeratorHost^ ForEachEnumerator {
    ForEachEnumeratorHost^ get ();
    void set (ForEachEnumeratorHost^ value);
}
member ForEachEnumerator : ForEachEnumeratorHost with get, set
function get ForEachEnumerator () : ForEachEnumeratorHost 
function set ForEachEnumerator (value : ForEachEnumeratorHost)

プロパティ値

型: Microsoft.SqlServer.Dts.Runtime.ForEachEnumeratorHost
ForEachEnumeratorHost を返します。

使用例

次のコード例では、ForEachLoop と ForEachEnumerator をホストから作成します。

            // Create the new application and package.
            Application app = new Application();
            Package package = new Package();

            // Create ForEachLoop task
            Executables executables = package.Executables;
            ForEachLoop forEachLoop = executables.Add("STOCK:FOREACHLOOP") as ForEachLoop;
 
            // Create a VariableMappings and VariableMapping objects.
            ForEachVariableMappings forEachVariableMappings = forEachLoop.VariableMappings;
            ForEachVariableMapping forEachVariableMapping = forEachVariableMappings.Add();

            // Create a mapping between the variable and its value.
            forEachVariableMapping.VariableName = @"Id";
            forEachVariableMapping.ValueIndex = 0;

            // Create a ForEachEnumeratorInfo from the application.
            // Create a Host for the ForEachItem enumerator.
            // Set the CollectionEnumerator to true to indicate that 
            // the iteration is over a collection.
            ForEachEnumeratorInfo forEachEnumeratorInfo = app.ForEachEnumeratorInfos["Foreach Item Enumerator"];
            ForEachEnumeratorHost forEachEnumeratorHost = forEachEnumeratorInfo.CreateNew();
            forEachEnumeratorHost.CollectionEnumerator = true;

            // Create the appropriate type of ForEachEnumerator from the host.
            forEachLoop.ForEachEnumerator = forEachEnumeratorHost;

            // Setup the Collection enumerator.
            ForEachItemEnumerator forEachItemEnumerator = forEachEnumeratorHost.InnerObject as ForEachItemEnumerator;

            ForEachItem forEachItem = forEachItemEnumerator.Items.Add();
            ForEachItemValue forEachItemValue = forEachItem.Add();
            forEachItemValue.Value = 1;
            forEachItemValue = forEachItem.Add();
            forEachItemValue.Value = "A";

            // Add other tasks to ForEachLoop container
            // and set appropriate values.

            // Run the package.
            DTSExecResult status = package.Execute();
            ' Create the new application and package.
            Dim app As Application =  New Application() 
            Dim package As Package =  New Package() 
 
            ' Create ForEachLoop task
            Dim executables As Executables =  package.Executables 
            Dim forEachLoop As ForEachLoop =  executables.Add("STOCK:FOREACHLOOP") as ForEachLoop 
 
            ' Create a VariableMappings and VariableMapping objects.
            Dim forEachVariableMappings As ForEachVariableMappings =  forEachLoop.VariableMappings 
            Dim forEachVariableMapping As ForEachVariableMapping =  forEachVariableMappings.Add() 
 
            ' Create a mapping between the variable and its value.
            forEachVariableMapping.VariableName = "Id"
            forEachVariableMapping.ValueIndex = 0
 
            ' Create a ForEachEnumeratorInfo from the application.
            ' Create a Host for the ForEachItem enumerator.
            ' Set the CollectionEnumerator to true to indicate that 
            ' the iteration is over a collection.
            Dim forEachEnumeratorInfo As ForEachEnumeratorInfo =  app.ForEachEnumeratorInfos("Foreach Item Enumerator") 
            Dim forEachEnumeratorHost As ForEachEnumeratorHost =  forEachEnumeratorInfo.CreateNew() 
            forEachEnumeratorHost.CollectionEnumerator = True
 
            ' Create the appropriate type of ForEachEnumerator from the host.
            forEachLoop.ForEachEnumerator = forEachEnumeratorHost
 
            ' Setup the Collection enumerator.
            Dim forEachItemEnumerator As ForEachItemEnumerator =  forEachEnumeratorHost.InnerObject as ForEachItemEnumerator 
 
            Dim forEachItem As ForEachItem =  forEachItemEnumerator.Items.Add() 
            Dim forEachItemValue As ForEachItemValue =  forEachItem.Add() 
            forEachItemValue.Value = 1
            forEachItemValue = forEachItem.Add()
            forEachItemValue.Value = "A"
 
            ' Add other tasks to ForEachLoop container
            ' and set appropriate values.
 
            ' Run the package.
            Dim status As DTSExecResult =  package.Execute()

関連項目

参照

ForEachLoop クラス

Microsoft.SqlServer.Dts.Runtime 名前空間