SqlMethodAttribute 类
定义
指示用户定义类型 (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
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)]
public sealed class SqlMethodAttribute : Microsoft.SqlServer.Server.SqlFunctionAttribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)>]
[<System.Serializable>]
type SqlMethodAttribute = class
inherit SqlFunctionAttribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)>]
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 和中的 TableDefinition 字段 SqlFunctionAttribute 。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() |
用户定义类型 (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 |
指示函数是否需要访问存储在 SQL Server 的本地实例中的用户数据。Indicates whether the function involves access to user data stored in the local instance of SQL Server. (继承自 SqlFunctionAttribute) |
| 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. (继承自 SqlFunctionAttribute) |
| InvokeIfReceiverIsNull |
指示 SQL Server 是否应在 null 实例上调用此方法。Indicates whether SQL Server should invoke the method on null instances. |
| IsDeterministic |
指示用户定义的函数是否是确定性的。Indicates whether the user-defined function is deterministic. (继承自 SqlFunctionAttribute) |
| IsMutator |
指示用户定义类型 (UDT) 的方法是否为转变器。Indicates whether a method on a user-defined type (UDT) is a mutator. |
| IsPrecise |
指示函数是否涉及不精确的计算,如浮点运算。Indicates whether the function involves imprecise computations, such as floating point operations. (继承自 SqlFunctionAttribute) |
| Name |
函数在 SQL Server 中注册时所使用的名称。The name under which the function should be registered in SQL Server. (继承自 SqlFunctionAttribute) |
| OnNullCall |
在方法调用中使用 |
| SystemDataAccess |
指示函数是否需要访问存储在 SQL Server 的系统目录或虚拟系统表中的数据。Indicates whether the function requires access to data stored in the system catalogs or virtual system tables of SQL Server. (继承自 SqlFunctionAttribute) |
| TableDefinition |
如果方法用作表值函数 (TVF),则为一个字符串,该字符串表示结果的表定义。A string that represents the table definition of the results, if the method is used as a table-valued function (TVF). (继承自 SqlFunctionAttribute) |
| TypeId |
在派生类中实现时,获取此 Attribute 的唯一标识符。When implemented in a derived class, gets a unique identifier for this Attribute. (继承自 Attribute) |
方法
| Equals(Object) |
返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object. (继承自 Attribute) |
| GetHashCode() |
返回此实例的哈希代码。Returns the hash code for this instance. (继承自 Attribute) |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| IsDefaultAttribute() |
在派生类中重写时,指示此实例的值是否是派生类的默认值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (继承自 Attribute) |
| Match(Object) |
当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (继承自 Attribute) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |
显式接口实现
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers. (继承自 Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can be used to get the type information for an interface. (继承自 Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1). (继承自 Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object. (继承自 Attribute) |