SafeToPrepareAttribute 类

Marks the methods in the assembly that are safe to run with the ExecuteForPrepare property set to true.

继承层次结构

System. . :: . .Object
  System. . :: . .Attribute
    Microsoft.AnalysisServices.AdomdServer..::..SafeToPrepareAttribute

命名空间:  Microsoft.AnalysisServices.AdomdServer
程序集:  msmgdsrv(在 msmgdsrv.dll 中)

语法

声明
Public NotInheritable Class SafeToPrepareAttribute _
    Inherits Attribute
用法
Dim instance As SafeToPrepareAttribute
public sealed class SafeToPrepareAttribute : Attribute
public ref class SafeToPrepareAttribute sealed : public Attribute
[<SealedAttribute>]
type SafeToPrepareAttribute =  
    class
        inherit Attribute
    end
public final class SafeToPrepareAttribute extends Attribute

SafeToPrepareAttribute 类型公开以下成员。

构造函数

  名称 说明
公共方法 SafeToPrepareAttribute Initializes a new instance of the SafeToPrepareAttribute class.

页首

属性

  名称 说明
公共属性 IsSafeToPrepare Gets a value that indicates whether the associated method is safe to run with the ExecuteForPrepare property set to true.
公共属性 TypeId (从 Attribute 继承。)

页首

方法

  名称 说明
公共方法 {dtor} Releases all resources used by the SafeToPrepareAttribute.
公共方法 Equals (从 Attribute 继承。)
受保护方法 Finalize (从 Object 继承。)
公共方法 GetHashCode (从 Attribute 继承。)
公共方法 GetType (从 Object 继承。)
公共方法 IsDefaultAttribute (从 Attribute 继承。)
公共方法 Match (从 Attribute 继承。)
受保护方法 MemberwiseClone (从 Object 继承。)
公共方法 ToString (从 Object 继承。)

页首

显式接口实现

  名称 说明
显式接口实现私有方法 _Attribute. . :: . .GetIDsOfNames (从 Attribute 继承。)
显式接口实现私有方法 _Attribute. . :: . .GetTypeInfo (从 Attribute 继承。)
显式接口实现私有方法 _Attribute. . :: . .GetTypeInfoCount (从 Attribute 继承。)
显式接口实现私有方法 _Attribute. . :: . .Invoke (从 Attribute 继承。)

页首

注释

If a user defined function (UDF) returns a DataTable, the UDF should be able to prepare for execution by running with the ExecuteForPrepare property set to true. To prepare for execution, the UDF should determine the structure of the DataTable needed to be returned, and return an empty DataTable that is structured appropriately.

示例

In the following example, a simple UDF creates a DataTable. If the UDF runs with the ExecuteForPrepare property set to true, the UDF returns with an empty version of the DataTable. If the UDF runs with the ExecuteForPrepare property set to false, the UDF continues, populates the DataTable, and returns the populated DataTable.

[SafeToPrepare(true)]
public System.Data.DataTable GetPreparedTable()
{
    System.Data.DataTable results = new System.Data.DataTable();
    results.Columns.Add("A", typeof(int));
    results.Columns.Add("B", typeof(string));

    if (Context.ExecuteForPrepare)
    {
        // If preparing, return just the schema with no data
        return results;
    }

    //Otherwise return data
    object[] row = new object[2];
    row[0] = 1;
    row[1] = "A";
    results.Rows.Add(row);

    row[0] = 2;
    row[1] = "B";
    results.Rows.Add(row);

    return results;
}

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。不保证所有实例成员都是线程安全的。