SqlMethodAttribute SqlMethodAttribute SqlMethodAttribute SqlMethodAttribute Class

定义

指示用户定义类型 (UDT) 的方法或属性的确定性和数据访问性质。Indicates the determinism and data access properties of a method or property on a user-defined type (UDT). 该特性的属性反映了向 SQL Server 注册该类型时所使用的实体特性。The properties on the attribute reflect the physical characteristics that are used when the type is registered with SQL Server.

public ref class SqlMethodAttribute sealed : Microsoft::SqlServer::Server::SqlFunctionAttribute
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)]
[System.Serializable]
public sealed class SqlMethodAttribute : Microsoft.SqlServer.Server.SqlFunctionAttribute
type SqlMethodAttribute = class
    inherit SqlFunctionAttribute
Public NotInheritable Class SqlMethodAttribute
Inherits SqlFunctionAttribute
继承
属性

示例

下面的示例演示了一个 UDT 方法, 该方法具有以下特性: 指示将不会在类型的 null 实例上调用方法, 方法不会更改类型的状态, 并且在参数为时null将不会调用该方法提供给方法调用。The following example shows a UDT method that is attributed to indicate that the method will not be invoked on null instances of the type, that the method will not change the state of the type, and that the method will not be called when null parameters are supplied to the method invocation.

// Distance from Point to the specified x and y values method.
[SqlMethod(OnNullCall = false, IsMutator=false, InvokeIfReceiverIsNull=false)]
public Double DistanceFromXY(Int32 iX, Int32 iY)
{
   return Math.Sqrt(Math.Pow(iX - _x, 2.0) + Math.Pow(iY - _y, 2.0));
}
' Distance from Point to the specified x and y values method.
<SqlMethod(OnNullCall:=False, IsMutator:=False, InvokeIfReceiverIsNull:=False)> _
Public Function DistanceFromXY(ByVal ix As Int32, ByVal iy As Int32) _
    As Double

    Return Math.Sqrt(Math.Pow(ix - _x, 2.0) + Math.Pow(iy - _y, 2.0))

End Function

注解

对于属性, SqlMethodAttribute应直接在 setter 或 getter 上使用。For a property, the SqlMethodAttribute should be used on the setter or the getter directly.

SqlMethodAttribute继承SqlFunctionAttribute自, 因此SqlMethodAttribute继承了和FillRowMethodName TableDefinitionSqlFunctionAttribute的字段。SqlMethodAttribute inherits from a SqlFunctionAttribute, so SqlMethodAttribute inherits the FillRowMethodName and TableDefinition fields from SqlFunctionAttribute. 请注意, 虽然这些字段的名称可能会表明可能, 但不能编写表值方法。Note that it is not possible to write a table-valued method, although the names of these fields might suggest that it is possible.

构造函数

SqlMethodAttribute() SqlMethodAttribute() SqlMethodAttribute() SqlMethodAttribute()

用户定义类型 (UDT) 的特性,用于指示 UDT 的方法或属性的确定性和数据访问性质。An attribute on a user-defined type (UDT), used to indicate the determinism and data access properties of a method or a property on a UDT.

属性

DataAccess DataAccess DataAccess DataAccess

指示函数是否需要访问存储在 SQL Server 的本地实例中的用户数据。Indicates whether the function involves access to user data stored in the local instance of SQL Server.

(Inherited from SqlFunctionAttribute)
FillRowMethodName FillRowMethodName FillRowMethodName FillRowMethodName

同一类中的方法名称,该类用于填充表值函数返回的表中的一行数据。The name of a method in the same class which is used to fill a row of data in the table returned by the table-valued function.

(Inherited from SqlFunctionAttribute)
InvokeIfReceiverIsNull InvokeIfReceiverIsNull InvokeIfReceiverIsNull InvokeIfReceiverIsNull

指示 SQL Server 是否应在 null 实例上调用此方法。Indicates whether SQL Server should invoke the method on null instances.

IsDeterministic IsDeterministic IsDeterministic IsDeterministic

指示用户定义的函数是否是确定性的。Indicates whether the user-defined function is deterministic.

(Inherited from SqlFunctionAttribute)
IsMutator IsMutator IsMutator IsMutator

指示用户定义类型 (UDT) 的方法是否为转变器。Indicates whether a method on a user-defined type (UDT) is a mutator.

IsPrecise IsPrecise IsPrecise IsPrecise

指示函数是否涉及不精确的计算,如浮点运算。Indicates whether the function involves imprecise computations, such as floating point operations.

(Inherited from SqlFunctionAttribute)
Name Name Name Name

函数在 SQL Server 中注册时所使用的名称。The name under which the function should be registered in SQL Server.

(Inherited from SqlFunctionAttribute)
OnNullCall OnNullCall OnNullCall OnNullCall

在方法调用中使用 null 输入参数时指示是否调用用户定义类型 (UDT) 上的方法。Indicates whether the method on a user-defined type (UDT) is called when null input arguments are specified in the method invocation.

SystemDataAccess SystemDataAccess SystemDataAccess SystemDataAccess

指示函数是否需要访问存储在 SQL Server 的系统目录或虚拟系统表中的数据。Indicates whether the function requires access to data stored in the system catalogs or virtual system tables of SQL Server.

(Inherited from SqlFunctionAttribute)
TableDefinition TableDefinition TableDefinition TableDefinition

如果方法用作表值函数 (TVF),则为一个字符串,该字符串表示结果的表定义。A string that represents the table definition of the results, if the method is used as a table-valued function (TVF).

(Inherited from SqlFunctionAttribute)
TypeId TypeId TypeId TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from Attribute)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

(Inherited from Attribute)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)
Match(Object) Match(Object) Match(Object) Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

显式界面实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(Inherited from Attribute)

适用于