次の方法で共有


ForLoop.PrecedenceConstraints Property

PrecedenceConstraints コレクションを返します。このフィールドは読み取り専用です。

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

構文

'宣言
Public ReadOnly Property PrecedenceConstraints As PrecedenceConstraints
public PrecedenceConstraints PrecedenceConstraints { get; }
public:
virtual property PrecedenceConstraints^ PrecedenceConstraints {
    PrecedenceConstraints^ get () sealed;
}
/** @property */
public final PrecedenceConstraints get_PrecedenceConstraints ()
public final function get PrecedenceConstraints () : PrecedenceConstraints

プロパティ値

PrecedenceConstraints コレクションです。

解説

優先順位制約は、パッケージ内の実行可能オブジェクトを順序付きワークフローにリンクし、実行可能オブジェクトの実行条件を指定します。

使用例

次のコード例では、ForLoop を作成し、3 つの式プロパティを設定します。また、ForLoop には、優先順位制約が設定された 2 つのタスクが含まれます。この優先順位制約は、ループの PrecedenceConstraints コレクションに追加されます。

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.SendMailTask;
using Microsoft.SqlServer.Dts.Tasks.BulkInsertTask;

namespace ForLoopAPI
{
    class Program
    {
        static void Main(string[] args)
        {
            String varName = "MyVariable";
            int INIT_COUNT = 2;
            int MAX_COUNT = 5;

            Package pkg = new Package();
            Variable var = pkg.Variables.Add(varName, false, "", 0);
            Variable var2 = pkg.Variables.Add("Counter", false, "", 0);

            ForLoop forLoop = (ForLoop)pkg.Executables.Add("STOCK:ForLoop");
            forLoop.InitExpression = "@"+varName+" = "+INIT_COUNT;
            forLoop.EvalExpression = "@"+varName+" < "+MAX_COUNT;
            forLoop.AssignExpression = "@" + varName + " = @" + varName + " + " + INIT_COUNT;

            // Show a different syntax for setting these values.
            //forLoop.InitExpression = "@Counter = 1";
            //forLoop.AssignExpression = "@Counter = @Counter + 1";
            //forLoop.EvalExpression = "@Counter <= 10";

            // The ForLoop contains a Properties collection. 
           // Show how to set some properties using that collection.
            forLoop.Properties["Name"].SetValue(forLoop, "ForLoop Container");
            forLoop.Properties["Description"].SetValue(forLoop, "ForLoop Container");


            // Review the PackagePath of the ForLoop container.
            Console.WriteLine("PackagePath: {0}", forLoop.GetPackagePath());

            // Because the ForLoop is a container, it can contain tasks
            // that run at certain conditions.
            TaskHost thLoopMail = (TaskHost)forLoop.Executables.Add("STOCK:SendMailTask");
            TaskHost thLoopInsert = (TaskHost)forLoop.Executables.Add("STOCK:BulkInsertTask");
            Executables loopExecs = forLoop.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 = forLoop.PrecedenceConstraints.Add((Executable)thLoopMail, thLoopInsert);
            PrecedenceConstraints pcs = forLoop.PrecedenceConstraints;
            Console.WriteLine("Number of precedence constraints: {0}", pcs.Count);


            // Run the package. Because required properties on the tasks are not
            //  set, current sample code will fail.
            DTSExecResult result = pkg.Execute();
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.SendMailTask
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask

Namespace ForLoopAPI

   Class Program

      'Entry point which delegates to C-style main Private Function
      Public Overloads Shared Sub Main()
         Main(System.Environment.GetCommandLineArgs())
      End Sub
      
      Overloads Shared Sub Main(args() As String)
         Dim varName As String = "MyVariable"
         Dim INIT_COUNT As Integer = 2
         Dim MAX_COUNT As Integer = 5
         
         Dim pkg As New Package()
         Dim var As Variable = pkg.Variables.Add(varName, False, "", 0)
         Dim var2 As Variable = pkg.Variables.Add("Counter", False, "", 0)
         
         Dim forLoop As ForLoop = CType(pkg.Executables.Add("STOCK:ForLoop"), ForLoop)
         forLoop.InitExpression = "@" + varName + " = " + INIT_COUNT
         forLoop.EvalExpression = "@" + varName + " < " + MAX_COUNT
         forLoop.AssignExpression = "@" + varName + " = @" + varName + " + " + INIT_COUNT
         
         ' Show a different syntax for setting these values.
         forLoop.InitExpression = "@Counter = 1"
         forLoop.AssignExpression = "@Counter = @Counter + 1"
         forLoop.EvalExpression = "@Counter <= 10"
         ' The ForLoop contains a Properties collection. 
         ' Show how to set some properties using that collection.
         forLoop.Properties("Name").SetValue(forLoop, "ForLoop Container")
         forLoop.Properties("Description").SetValue(forLoop, "ForLoop Container")
         
         
         ' Review the PackagePath of the ForLoop container.
         Console.WriteLine("PackagePath: {0}", forLoop.GetPackagePath())
         
         ' Because the ForLoop is a container, it can contain tasks
         ' that run at certain conditions.
         Dim thLoopMail As TaskHost = CType(forLoop.Executables.Add("STOCK:SendMailTask"), TaskHost)
         Dim thLoopInsert As TaskHost = CType(forLoop.Executables.Add("STOCK:BulkInsertTask"), TaskHost)
         Dim loopExecs As Executables = forLoop.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 = forLoop.PrecedenceConstraints.Add(CType(thLoopMail, Executable), thLoopInsert)
         Dim pcs As PrecedenceConstraints = forLoop.PrecedenceConstraints
         Console.WriteLine("Number of precedence constraints: {0}", pcs.Count)
         
         
         ' Run the package. Because required properties on the tasks are not
         '  set, current sample code will fail.
         Dim result As DTSExecResult = pkg.Execute()
      End Sub 'Main
   End Class 'Program
End Namespace 'ForLoopAPI

サンプルの出力 :

PackagePath: \Package\{8A18B94E-1176-429E-BB3D-6F3F1E0C9070}

Number of Executables in ForLoop: 2

Number of precedence constraints: 1

スレッド セーフ

この型の public static (Microsoft Visual Basic では共有 ) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

プラットフォーム

開発プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

対象プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

参照

関連項目

ForLoop Class
ForLoop Members
Microsoft.SqlServer.Dts.Runtime Namespace