ForEachLoop.Executables 属性

定义

返回在 Executable 执行期间由数据转换运行时引擎处理的 ForEachLoop 对象的集合。 此字段为只读。

public:
 property Microsoft::SqlServer::Dts::Runtime::Executables ^ Executables { Microsoft::SqlServer::Dts::Runtime::Executables ^ get(); };
public Microsoft.SqlServer.Dts.Runtime.Executables Executables { get; }
member this.Executables : Microsoft.SqlServer.Dts.Runtime.Executables
Public ReadOnly Property Executables As Executables

属性值

Executables 集合。

实现

示例

下面的代码示例使用Properties集合创建ForEachLoop并设置一些属性。 将两个任务添加到 Executables 集合中,并在它们之间放置优先约束。

// Create the package.  
Package package = new Package();  
// Add variables.  
package.Variables.Add("Id", false, "User", 0);  

// Create ForEachLoop task  
Executables executables = package.Executables;  
ForEachLoop forEachLoop = executables.Add("STOCK:FOREACHLOOP") as ForEachLoop;  

// The ForEachLoop is a container. Add some task executables and  
// create a precedence constraint. The tasks can run when  
// certain conditions in the loop are met.  
TaskHost thLoopMail = (TaskHost)forEachLoop.Executables.Add("STOCK:SendMailTask");  
TaskHost thLoopInsert = (TaskHost)forEachLoop.Executables.Add("STOCK:BulkInsertTask");  
Executables loopExecs = forEachLoop.Executables;  
Console.WriteLine("Number of Executables in ForLoop: {0}", loopExecs.Count);  

// Like other containers, precedence constraints can be set on the  
// contained tasks.  
PrecedenceConstraint pc = forEachLoop.PrecedenceConstraints.Add((Executable)thLoopMail, thLoopInsert);  
PrecedenceConstraints pcs = forEachLoop.PrecedenceConstraints;  
Console.WriteLine("Number of precedence constraints: {0}", pcs.Count);  
' Create the package.  
Dim package As Package =  New Package()   
' Add variables.  
package.Variables.Add("Id", False, "User", 0)  

' Create ForEachLoop task  
Dim executables As Executables =  package.Executables   
Dim forEachLoop As ForEachLoop =  executables.Add("STOCK:FOREACHLOOP") as ForEachLoop   

' The ForEachLoop is a container. Add some task executables and  
' create a precedence constraint. The tasks can run when  
' certain conditions in the loop are met.  
Dim thLoopMail As TaskHost = CType(forEachLoop.Executables.Add("STOCK:SendMailTask"), TaskHost)  
Dim thLoopInsert As TaskHost = CType(forEachLoop.Executables.Add("STOCK:BulkInsertTask"), TaskHost)  
Dim loopExecs As Executables =  forEachLoop.Executables   
Console.WriteLine("Number of Executables in ForLoop: {0}", loopExecs.Count)  

' Like other containers, precedence constraints can be set on the  
' contained tasks.  
Dim pc As PrecedenceConstraint =  forEachLoop.PrecedenceConstraints.Add(CType(thLoopMail,thLoopInsert, Executable))   
Dim pcs As PrecedenceConstraints =  forEachLoop.PrecedenceConstraints   
Console.WriteLine("Number of precedence constraints: {0}", pcs.Count)  

示例输出:

ForLoop 中的可执行文件数:2

优先约束数:1

适用于