ForEachEnumeratorHost.GetExpression Method (String)


Returns a String that contains the expression for the specified property. Null means no expression is assigned.

Namespace:   Microsoft.SqlServer.Dts.Runtime
Assembly:  Microsoft.SqlServer.ManagedDTS (in Microsoft.SqlServer.ManagedDTS.dll)

public string GetExpression(
	string propertyName


Type: System.String

The name of the property whose expression you want to see.

Return Value

Type: System.String

A String that contains the expression used to evaluate the property.

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();
            // 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);

Sample Output:

DelayValidation: False

New DelayValidation: False

Expression: true

Return to top