Export (0) Print
Expand All

Package.GetExpression Method

Returns a value 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
)

Parameters

propertyName
Type: String
The name of the property whose expression you want to see.

Return Value

Type: String
A value that contains the expression used to evaluate the property.

Implements

IDTSPropertiesProvider.GetExpression(String)

The propertyName can be any property available on the object.

The following code example modifies the value of the DelayValidation property using SetExpression, then displays the new value using 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);
        }
    }
}

Sample Output:

value before is False

The value and expression is True, true

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft