Поделиться через


Класс 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.)
Открытый метод GetHashCode (Производный от Attribute.)
Открытый метод GetType (Производный от Object.)
Открытый метод IsDefaultAttribute (Производный от Attribute.)
Открытый метод Match (Производный от Attribute.)
Открытый метод 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;
}

Безопасность многопоточности

Любые открытые статический (Shared в Visual Basic) элементы этого типа потокобезопасны. Потокобезопасность с элементами экземпляров не гарантируется.

См. также

Справочник

Пространство имен Microsoft.AnalysisServices.AdomdServer