Variable.EvaluateAsExpression 屬性

定義

取得或設定布林值,指出變數是否包含運算式。

public:
 property bool EvaluateAsExpression { bool get(); void set(bool value); };
[Microsoft.SqlServer.Dts.Runtime.Localization.LocalizablePropertyDescription(typeof(Microsoft.SqlServer.Dts.Runtime.Localized), "EvaluateAsExpressionDesc")]
public bool EvaluateAsExpression { get; set; }
[<Microsoft.SqlServer.Dts.Runtime.Localization.LocalizablePropertyDescription(typeof(Microsoft.SqlServer.Dts.Runtime.Localized), "EvaluateAsExpressionDesc")>]
member this.EvaluateAsExpression : bool with get, set
Public Property EvaluateAsExpression As Boolean

屬性值

Boolean

如果變數包含運算式,則為 true;否則為 false。

屬性

範例

下列範例會設定旗標, 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

備註

運算式和變數可以用來控制封裝的流程。 如需詳細資訊,請參閱 將運算式加入優先順序條件約束

適用於