Variable.Expression 属性

定义

获取或设置包含在变量中的表达式。

public:
 property System::String ^ Expression { System::String ^ get(); void set(System::String ^ value); };
[Microsoft.SqlServer.Dts.Runtime.Localization.LocalizablePropertyDescription(typeof(Microsoft.SqlServer.Dts.Runtime.Localized), "ExpressionDesc")]
public string Expression { get; set; }
[<Microsoft.SqlServer.Dts.Runtime.Localization.LocalizablePropertyDescription(typeof(Microsoft.SqlServer.Dts.Runtime.Localized), "ExpressionDesc")>]
member this.Expression : string with get, set
Public Property Expression As String

属性值

包含表达式的字符串。

属性

示例

以下示例设置标志 EvaluateAsExpression 以显示变量包含表达式,然后可以使用该 Expression 属性。

static void Main(string[] args)  
    {  
        Package p = new Package();  
        p.Variables.Add("x", false, "", 1);  
        Variable v = p.Variables.Add("y", false, "", 1);  
        v.Expression = "@x + 10";  
        v.EvaluateAsExpression = true;  
        if (v.Value.ToString() == "11")  
            Console.WriteLine("Value was 11");  
        else  
            Console.WriteLine("Value was not 11");  
    }  
Shared  Sub Main(ByVal args() As String)  
        Dim p As Package =  New Package()   
        p.Variables.Add("x", False, "", 1)  
        Dim v As Variable =  p.Variables.Add("y",False,"",1)   
        v.Expression = "@x + 10"  
        v.EvaluateAsExpression = True  
        If v.Value.ToString() = "11" Then  
            Console.WriteLine("Value was 11")  
        Else   
            Console.WriteLine("Value was not 11")  
        End If  
End Sub  

示例输出:

值为 11

注解

该方法Expression仅在属性设置为 trueEvaluateAsExpression返回值属性中输入的表达式;否则,如果false返回空字符串。

适用于