다음을 통해 공유


ForEachEnumeratorHost.SetExpression Method

Assigns the specified expression to the property. Specify null to remove an existing expression from the property.

네임스페이스: Microsoft.SqlServer.Dts.Runtime
어셈블리: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

구문

‘선언
Public Sub SetExpression ( _
    propertyName As String, _
    expression As String _
)
public void SetExpression (
    string propertyName,
    string expression
)
public:
virtual void SetExpression (
    String^ propertyName, 
    String^ expression
) sealed
public final void SetExpression (
    String propertyName, 
    String expression
)
public final function SetExpression (
    propertyName : String, 
    expression : String
)

매개 변수

  • propertyName
    The name of the property to which to assign the expression.
  • expression
    The expression.

The following code example hosts a SMO enumerator in the ForEachEnumeratorHost. Using the SetExpression method, the DelayValidation property is modified, then the expression is retrieved using the GetExpression method.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;

namespace Microsoft.SqlServer.SSIS.Sample
{
    internal class EnumType
    {
        public const string SMOEnum = "Foreach SMO Enumerator";
    }
    class SSISProgram
    {
        static void Main(string[] args)
        {
            Application app = new Application();
            Package pkg = new Package();
            ForEachEnumeratorInfos infos = app.ForEachEnumeratorInfos;
            ForEachEnumeratorInfo info = null;

            foreach (ForEachEnumeratorInfo enumInfo in infos)
            {
                // Uncomment the next line of you want to see all enumerators.
                //Console.Write("Available enumerators: {0}\n", enumInfo.Name);
                if (enumInfo.Name == EnumType.SMOEnum)
                {
                    // Set the ForEachEnumeratorInfo variable
                    // to the SMO enumerator, and use it 
                    // later in the CreateNew method.
                    info = enumInfo;
                }
            }
            ForEachEnumeratorHost enumH = info.CreateNew();
            Console.WriteLine();
            // Show the description before it is modified.
            Console.WriteLine("DelayValidation:  {0}", enumH.DelayValidation);

            // Modify the Description using SetExpression.
            //String myExpression = "\"My Description for SMO enumerator\"";
            String myExpression = "true";
            enumH.SetExpression("DelayValidation", myExpression);

            DTSExecResult result = pkg.Validate(null, null, null, null);

            // Review the new value and expression.
            String newExpr = enumH.GetExpression("DelayValidation");
            Console.WriteLine("New DelayValidation: {0}", enumH.DelayValidation);
            Console.WriteLine("Expression:      {0}", newExpr);
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime

Friend Class EnumType
    Public Const SMOEnum As String = "Foreach SMO Enumerator"
End Class 'EnumType

Class SSISProgram
    
    Shared Sub Main(ByVal args() As String) 
        Dim app As New Application()
        Dim pkg As New Package()
        Dim infos As ForEachEnumeratorInfos = app.ForEachEnumeratorInfos
        Dim info As ForEachEnumeratorInfo = Nothing
        
        Dim enumInfo As ForEachEnumeratorInfo
        For Each enumInfo In  infos
            ' Uncomment the next line of you want to see all enumerators.
            'Console.Write("Available enumerators: {0}\n", enumInfo.Name);
            If enumInfo.Name = EnumType.SMOEnum Then
                ' Set the ForEachEnumeratorInfo variable
                ' to the SMO enumerator, and use it 
                ' later in the CreateNew method.
                info = enumInfo
            End If
        Next enumInfo
        Dim enumH As ForEachEnumeratorHost = info.CreateNew()
        Console.WriteLine()
        ' Show the description before it is modified.
        Console.WriteLine("DelayValidation:  {0}", enumH.DelayValidation)
        
        ' Modify the Description using SetExpression.
        'String myExpression = "\"My Description for SMO enumerator\"";
        Dim myExpression As String = "true"
        enumH.SetExpression("DelayValidation", myExpression)
        
        Dim result As DTSExecResult = pkg.Validate(Nothing, Nothing, Nothing, Nothing)
        
        ' Review the new value and expression.
        Dim newExpr As String = enumH.GetExpression("DelayValidation")
        Console.WriteLine("New DelayValidation: {0}", enumH.DelayValidation)
        Console.WriteLine("Expression:      {0}", newExpr)
    
    End Sub 'Main
End Class 'SSISProgram

Sample Output:

DelayValidation: False

New DelayValidation: False

Expression: true

스레드 보안

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

플랫폼

개발 플랫폼

지원되는 플랫폼 목록은 SQL Server 2005 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.

대상 플랫폼

지원되는 플랫폼 목록은 SQL Server 2005 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.

참고 항목

참조

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