SqlUserDefinedTypeAttribute SqlUserDefinedTypeAttribute SqlUserDefinedTypeAttribute SqlUserDefinedTypeAttribute Class

定义

用于将程序集中的类型定义标记为 SQL Server 中的用户定义类型 (UDT)。Used to mark a type definition in an assembly as a user-defined type (UDT) in SQL Server. 该特性的属性反映了向 SQL Server 注册该类型时所使用的实体特征。The properties on the attribute reflect the physical characteristics used when the type is registered with SQL Server. 此类不能被继承。This class cannot be inherited.

public ref class SqlUserDefinedTypeAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct, AllowMultiple=false, Inherited=true)]
public sealed class SqlUserDefinedTypeAttribute : Attribute
type SqlUserDefinedTypeAttribute = class
    inherit Attribute
Public NotInheritable Class SqlUserDefinedTypeAttribute
Inherits Attribute
继承
SqlUserDefinedTypeAttributeSqlUserDefinedTypeAttributeSqlUserDefinedTypeAttributeSqlUserDefinedTypeAttribute
属性

示例

下面的示例演示UserDefinedType点 UDT 的特性。The following example shows the UserDefinedType attribute of the Point UDT. UDT 按字节顺序排序, 命名为 "Point", 包含一个名为 "ValidatePoint" 的验证方法, 并使用本机序列化格式。The UDT is byte-ordered, is named "Point", has a validation method named "ValidatePoint", and uses the native serialization format.

[Serializable]
[Microsoft.SqlServer.Server.SqlUserDefinedType(Format.Native,
     IsByteOrdered=true,  
     Name="Point",ValidationMethodName = "ValidatePoint")]
public struct Point : INullable
{
<Serializable(), SqlUserDefinedTypeAttribute(Format.Native, _
  IsByteOrdered:=True, _
  Name:="Point", _
  ValidationMethodName:="ValidatePoint")> _
  Public Structure Point
    Implements INullable

注解

SQL Server 创建一个用户定义的类型, 该类型绑定到具有SqlUserDefinedTypeAttribute自定义属性的类型定义。SQL Server creates a user-defined type that is bound to the type definition that has the SqlUserDefinedTypeAttribute custom attribute. 每个 UDT 都必须用此属性进行批注。Every UDT must be annotated with this attribute. 有关 Udt 的详细信息 (包括 UDT 的示例), 请参阅CLR 用户定义类型See CLR User-Defined Types for more information about UDTs, including an example of a UDT.

构造函数

SqlUserDefinedTypeAttribute(Format) SqlUserDefinedTypeAttribute(Format) SqlUserDefinedTypeAttribute(Format) SqlUserDefinedTypeAttribute(Format)

用户定义类型 (UDT) 的一个必需特性,用于确认给定的类型属于 UDT 并指示 UDT 的存储格式。A required attribute on a user-defined type (UDT), used to confirm that the given type is a UDT and to indicate the storage format of the UDT.

属性

Format Format Format Format

序列化格式为 Format 的值之一。The serialization format as a Format.

IsByteOrdered IsByteOrdered IsByteOrdered IsByteOrdered

指示用户定义的类型是否根据字节进行排序。Indicates whether the user-defined type is byte ordered.

IsFixedLength IsFixedLength IsFixedLength IsFixedLength

指示此用户定义类型的所有实例是否都具有相同的长度。Indicates whether all instances of this user-defined type are the same length.

MaxByteSize MaxByteSize MaxByteSize MaxByteSize

实例的最大大小(以字节为单位)。The maximum size of the instance, in bytes.

Name Name Name Name

用户定义类型的 SQL Server 名称。The SQL Server name of the user-defined type.

TypeId TypeId TypeId TypeId

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

(Inherited from Attribute)
ValidationMethodName ValidationMethodName ValidationMethodName ValidationMethodName

方法的名称,该方法用于验证用户定义类型的实例。The name of the method used to validate instances of the user-defined type.

方法

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)

适用于