Share via


TaskHost.GetExpression(String) Método

Definição

Retorna a expressão para a propriedade especificada. Nulo significa que nenhuma expressão é atribuída.

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

Parâmetros

propertyName
String

O nome da propriedade cuja expressão você deseja ver.

Retornos

Uma cadeia de caracteres que contém a expressão usada para avaliar a propriedade.

Implementações

Exemplos

O exemplo de código a seguir mostra como usar os métodos e GetExpression os SetExpression métodos do TaskHost. Para este exemplo de código, a tarefa hospedada é a 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);  
        }  
    }  
}  

Saída de exemplo:

Valor original de CheckConstraints: False

Novo valor de CheckConstraints: True

Expressão para CheckConstraints: true

Comentários

Pode propertyName ser qualquer propriedade disponível no objeto.

Aplica-se a