SqlFacetAttribute SqlFacetAttribute SqlFacetAttribute SqlFacetAttribute Class

定义

使用可用在 Transact-SQL 中的其他信息对用户定义类型 (UDT) 的返回结果进行批注。Annotates the returned result of a user-defined type (UDT) with additional information that can be used in Transact-SQL.

public ref class SqlFacetAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Parameter | System.AttributeTargets.Property | System.AttributeTargets.ReturnValue, AllowMultiple=false, Inherited=false)]
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field | System.AttributeTargets.Parameter | System.AttributeTargets.ReturnValue, AllowMultiple=false, Inherited=false)]
public class SqlFacetAttribute : Attribute
type SqlFacetAttribute = class
    inherit Attribute
Public Class SqlFacetAttribute
Inherits Attribute
继承
SqlFacetAttributeSqlFacetAttributeSqlFacetAttributeSqlFacetAttribute
属性

注解

SqlFacetAttribute 仅可以指定对非 void 返回值。SqlFacetAttribute may only be specified on non-void return values.

SqlFacetAttribute 仅用于派生的返回类型有关的信息并不是为约束指定类型中可以存储的内容。SqlFacetAttribute is used only to derive information about the return type, and is not intended to be a constraint specification on what can be stored in the type. 因此,如果字段具有SqlFacetAttribute,该值指示其大小为 2 个字符,然后字段访问表达式的 SQL Server 类型的大小为 2,但分配到该字段不受此方面。Thus, if a field has a SqlFacetAttribute indicating its size to be 2 characters, then the SQL Server type of the field access expression is of size 2, but assignments into the field are not restricted by this facet.

下表捕获特定的字段类型的各种属性的有效值的矩阵。The table below captures the matrix of valid values for the various properties for specific field types. 在此表中,"Y"表示该属性有效,"N"表示的属性不是有效。In this table, "Y" indicates that the property is valid, and "N" indicates that the property is not valid.

指定SqlFacetAttribute必须与字段类型兼容。The specified SqlFacetAttribute must be compatible with the field type. 如果属性不是有效的类型注册将报告错误,如果用户指定非默认值的属性。If the property is not valid, type registration will report an error if the user specifies a non-default value for the property. 最大值为PrecisionScale属性为 38。The maximum values for Precision and Scale properties are 38. 有关MaxSize属性,值应为 1 8000 二进制文件和非 Unicode 数据,1-4000 Unicode 数据,则为-1 范围内。For the MaxSize property, the value should be in the range of 1-8000 for binary and non-Unicode data, 1-4000 for Unicode data, or -1. 所有其他值不是有效的。All other values are not valid.

类型Type IsFixedLengthIsFixedLength 最大大小MaxSize 精度Precision 缩放Scale IsNullableIsNullable
SqlBoolean NN NN NN NN YY
SqlByte NN NN NN NN YY
SqlInt16 NN NN NN NN YY
SqlInt32 NN NN NN NN YY
SqlInt64 NN NN NN NN YY
SqlSingle NN NN NN NN YY
SqlDouble NN NN NN NN YY
SqlDateTime NN NN NN NN YY
SqlMoney NN NN NN NN YY
SqlGuid NN NN NN NN YY
SqlDecimal NN NN YY YY YY
SqlString YY YY NN NN YY
SqlBinary YY YY NN NN YY
SqlXml NN NN NN NN YY
SqlBytes YY YY NN NN YY
SqlChars YY YY NN NN YY
嵌入的 UdtEmbedded UDTs NN NN NN NN YY
String YY YY NN NN YY
Byte[]Byte[] YY YY NN NN YY
Char[]Char[] YY YY NN NN YY
DateTime NN NN NN Y1Y1 NN
Decimal NN NN YY YY YY

(1) 指定刻度上的日期时间类型将导致要返回到 TRANSACT-SQL 为具有指定的小数位数的 DateTime2 类型的值。(1) Specifying the scale on a DateTime type will cause the value to be returned to Transact-SQL as a DateTime2 type with the specified scale.

构造函数

SqlFacetAttribute() SqlFacetAttribute() SqlFacetAttribute() SqlFacetAttribute()

用户定义类型 (UDT) 返回类型的可选特性,该特性的用途是借助可以在 Transact-SQL 中使用的其他信息对返回的结果进行批注。An optional attribute on a user-defined type (UDT) return type, used to annotate the returned result with additional information that can be used in Transact-SQL.

属性

IsFixedLength IsFixedLength IsFixedLength IsFixedLength

指示用户定义类型的返回类型是否具有固定长度。Indicates whether the return type of the user-defined type is of a fixed length.

IsNullable IsNullable IsNullable IsNullable

指示用户定义类型的返回类型是否可以为 nullIndicates whether the return type of the user-defined type can be null.

MaxSize MaxSize MaxSize MaxSize

用户定义类型的基础字段类型的最大大小(用逻辑单元表示)。The maximum size, in logical units, of the underlying field type of the user-defined type.

Precision Precision Precision Precision

用户定义类型的返回类型的精度。The precision of the return type of the user-defined type.

Scale Scale Scale Scale

用户定义类型的返回类型的小数位数。The scale of the return type 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)

方法

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)

适用于