Package.SetExpression(String, String) 메서드

정의

지정한 식을 속성에 할당합니다. 속성에서 기존 식을 제거하려면 null을 지정합니다.

public:
 virtual void SetExpression(System::String ^ propertyName, System::String ^ expression);
public void SetExpression (string propertyName, string expression);
abstract member SetExpression : string * string -> unit
override this.SetExpression : string * string -> unit
Public Sub SetExpression (propertyName As String, expression As String)

매개 변수

propertyName
String

식을 할당할 속성의 이름입니다.

expression
String

식입니다.

구현

예제

다음 코드 예제에서는 사용 하 여 속성의 DelayValidation 값을 수정 하 고 SetExpression사용 하 여 GetExpression새 값을 표시 합니다.

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

namespace Microsoft.SqlServer.SSIS.Samples  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            Package pkg = new Package();  
            // Set an expression on one of the properties.  
            DtsProperties pkgProperties = pkg.Properties;  

            // View information about the DelayValidation property   
            // before setting it with the SetExpression method.  
            Object myValue = pkgProperties["DelayValidation"].GetValue(pkg);  
            String mySValue = myValue.ToString();  
            Console.WriteLine("value before is {0}", mySValue);   

            // Use SetExpression to set the value to true.  
            String myTrueString = "true";  
            pkgProperties["DelayValidation"].SetExpression(pkg, myTrueString);  

            // Validate the package to set the expression onto the property.  
            DTSExecResult valResult = pkg.Validate(null, null, null, null);  

            // Verify the new setting.  
            myValue = pkgProperties["DelayValidation"].GetValue(pkg);  
            mySValue = myValue.ToString();  

            String myExpression = pkg.Properties["DelayValidation"].GetExpression(pkg);  
            String mySExpression = myExpression.ToString();  
            Console.WriteLine("The value and expression is {0}, {1}", mySValue, mySExpression);  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Class Program  
    Shared Sub Main(ByVal args() As String)   
        Dim pkg As New Package()  
        ' Set an expression on one of the properties.  
        Dim pkgProperties As DtsProperties = pkg.Properties  

        ' View information about the DelayValidation property   
        ' before setting it with the SetExpression method.  
        Dim myValue As [Object] = pkgProperties("DelayValidation").GetValue(pkg)  
        Dim mySValue As String = myValue.ToString()  
        Console.WriteLine("value before is {0}", mySValue)  

        ' Use SetExpression to set the value to true.  
        Dim myTrueString As String = "true"  
        pkgProperties("DelayValidation").SetExpression(pkg, myTrueString)  

        ' Validate the package to set the expression onto the property.  
        Dim valResult As DTSExecResult = pkg.Validate(Nothing, Nothing, Nothing, Nothing)  

        ' Verify the new setting.  
        myValue = pkgProperties("DelayValidation").GetValue(pkg)  
        mySValue = myValue.ToString()  

        Dim myExpression As String = pkg.Properties("DelayValidation").GetExpression(pkg)  
        Dim mySExpression As String = myExpression.ToString()  
        Console.WriteLine("The value and expression is {0}, {1}", mySValue, mySExpression)  
    End Sub  
End Class  

샘플 출력:

value before is False

The value and expression is True, true

설명

개체 propertyName 에서 사용할 수 있는 모든 속성일 수 있습니다.

적용 대상