TaskHost.GetExpression Method

Returns the expression for the specified property. Null means no expression is assigned.

命名空間: Microsoft.SqlServer.Dts.Runtime
組件: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

語法

'宣告
Public Function GetExpression ( _
    propertyName As String _
) As String
public string GetExpression (
    string propertyName
)
public:
virtual String^ GetExpression (
    String^ propertyName
) sealed
public final String GetExpression (
    String propertyName
)
public final function GetExpression (
    propertyName : String
) : String

參數

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

傳回值

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

備註

The propertyName can be any property available on the object.

範例

The following code example shows how to use the SetExpression and GetExpression methods of the TaskHost. For this code example, the hosted task is the BulkInsertTask.

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


namespace Microsoft.SqlServer.SSIS.Sample
{
    class Program
        {
        static void Main(string[] args)
        {
            Package pkg = new Package();
            TaskHost th = (TaskHost)pkg.Executables.Add("STOCK:BulkInsertTask");

            // View information about the CheckConstraints property
            // before setting it using the SetExpression method.
            Boolean checkConstraint = (Boolean)th.Properties["CheckConstraints"].GetValue(th);
            Console.WriteLine("Original value of CheckConstraints: {0}", checkConstraint);

            // Use SetExpression to set the value to true.
            String myTrueString = "true";
            th.Properties["CheckConstraints"].SetExpression(th, myTrueString);

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

            // Retrieve the new value and the expression.
            checkConstraint = (Boolean)th.Properties["CheckConstraints"].GetValue(th);
            String myExpression = th.Properties["CheckConstraints"].GetExpression(th);
            Console.WriteLine("New value of CheckConstraints: {0}", checkConstraint);
            Console.WriteLine("Expression for CheckConstraints: {0}", myExpression);
        }
    }
}

Sample Output:

Original value of CheckConstraints: False

New value of CheckConstraints: True

Expression for CheckConstraints: 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 的硬體和軟體需求>。

請參閱

參考

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