Partager via


SafeToPrepareAttribute Class

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

Espace de noms: Microsoft.AnalysisServices.AdomdServer
Assembly: msmgdsrv (in msmgdsrv.dll)

Syntaxe

'Déclaration
<SuppressMessageAttribute("Microsoft.Design", "CA1018:MarkAttributesWithAttributeUsage")> _
<SuppressMessageAttribute("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")> _
Public NotInheritable Class SafeToPrepareAttribute
    Inherits Attribute
[SuppressMessageAttribute("Microsoft.Design", "CA1018:MarkAttributesWithAttributeUsage")] 
[SuppressMessageAttribute("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")] 
public sealed class SafeToPrepareAttribute : Attribute
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1018:MarkAttributesWithAttributeUsage")] 
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1019:DefineAccessorsForAttributeArguments")] 
public ref class SafeToPrepareAttribute sealed : public Attribute
/** @attribute SuppressMessageAttribute("Microsoft.Design", "CA1018:MarkAttributesWithAttributeUsage") */ 
/** @attribute SuppressMessageAttribute("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments") */ 
public final class SafeToPrepareAttribute extends Attribute
SuppressMessageAttribute("Microsoft.Design", "CA1018:MarkAttributesWithAttributeUsage") 
SuppressMessageAttribute("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments") 
public final class SafeToPrepareAttribute extends Attribute

Notes

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.

Inheritance Hierarchy

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

Exemple

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;
}

Sécurité des threads

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Plateformes

Plateformes de développement

Pour obtenir la liste des plateformes prises en charge, consultez Configuration matérielle et logicielle requise pour l'installation de SQL Server 2005.

Plateformes cibles

Pour obtenir la liste des plateformes prises en charge, consultez Configuration matérielle et logicielle requise pour l'installation de SQL Server 2005.

Voir aussi

Référence

SafeToPrepareAttribute Members
Microsoft.AnalysisServices.AdomdServer Namespace