Sequence.SetExpression(String, String) 方法  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将指定的表达式分配给属性。 指定 null 以从属性中删除现有表达式。
public:
 virtual void SetExpression(System::String ^ propertyName, System::String ^ expression);
	public void SetExpression (string propertyName, string expression);
	abstract member SetExpression : string * string -> unit
override this.SetExpression : string * string -> unit
	Public Sub SetExpression (propertyName As String, expression As String)
	参数
- propertyName
 - String
 
向其分配表达式的属性的名称。
- expression
 - String
 
表达式。
实现
示例
下面的代码示例用于SetExpression修改容器上的Sequence值Description。 然后 GetExpression 用于检索表达式。
using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  
namespace Microsoft.SqlServer.SSIS.Sample  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            const String containerName = "Sequence";  
            Package pkg = new Package();  
            Sequence sequence = (Sequence)pkg.Executables.Add("STOCK:Sequence");  
            DtsProperties seqProps = sequence.Properties;  
            // View information about the Description property  
            // before setting it using the SetExpression method.  
            String desc = sequence.Description;  
            Console.WriteLine("Original value of Description: {0}", desc);  
            // Use SetExpression to give the Sequence a description.  
            String myExpression = "\"Testing " + containerName + "\"";   
            sequence.SetExpression("Description", myExpression);  
            // Note that I've tried using the Properties bag instead, with no change to the results.  
            //seqProps["Description"].SetExpression(sequence, myExpression);   
            //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.  
            String myNewDesc = sequence.Description;  
            String myNewExpression = sequence.GetExpression("Description");  
            Console.WriteLine("New value of Description: {0}", myNewDesc);  
            Console.WriteLine("Expression for Description: {0}", myNewExpression);  
        }  
    }  
}  
示例输出:
说明的原始值:
说明的新值:测试序列
描述的表达式:“测试序列”
注解
可以是 propertyName 对象上可用的任何属性。