ForEachLoop.ForEachEnumerator 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
ForEachEnumerator에 대한 호스트를 가져오거나 설정합니다.
public:
property Microsoft::SqlServer::Dts::Runtime::ForEachEnumeratorHost ^ ForEachEnumerator { Microsoft::SqlServer::Dts::Runtime::ForEachEnumeratorHost ^ get(); void set(Microsoft::SqlServer::Dts::Runtime::ForEachEnumeratorHost ^ value); };
public Microsoft.SqlServer.Dts.Runtime.ForEachEnumeratorHost ForEachEnumerator { get; set; }
member this.ForEachEnumerator : Microsoft.SqlServer.Dts.Runtime.ForEachEnumeratorHost with get, set
Public Property ForEachEnumerator As 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()