ForEachEnumeratorHost.GetExpression(String) 方法

定义

返回一个字符串,该字符串包含指定属性的表达式。 Null 表示未分配任何表达式。

public:
 virtual System::String ^ GetExpression(System::String ^ propertyName);
public string GetExpression (string propertyName);
abstract member GetExpression : string -> string
override this.GetExpression : string -> string
Public Function GetExpression (propertyName As String) As String

参数

propertyName
String

要查看其表达式的属性的名称。

返回

包含用于计算属性的表达式的字符串。

实现

示例

下面的代码示例托管 SMO 枚举器。ForEachEnumeratorHost SetExpression使用该方法修改DelayValidation属性,然后使用该方法检索GetExpression表达式。

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  

示例输出:

DelayValidation: False

新的 DelayValidation: False

表达式:true

适用于