共用方式為


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) 成員都是執行緒安全的。並不是所有的執行個體成員都保證可以用於所有的執行緒。