SqlUserDefinedTypeAttribute 類別

定義

用於將組件中的型別定義在 SQL Server 中標記為使用者定義型別 (UDT)。 該屬性 (Attribute) 上的屬性 (Property) 反映使用 SQL Server 註冊型別時使用的實體特性。 此類別無法獲得繼承。

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

範例

下列範例顯示 UserDefinedType Point UDT 的 屬性。 UDT 是以位元組排序,名為 「Point」、具有名為 「ValidatePoint」 的驗證方法,並使用原生串行化格式。

using Microsoft.Data.SqlClient.Server;
using System.Data.SqlTypes;
using System.Text;

[Serializable]
[Microsoft.Data.SqlClient.Server.SqlUserDefinedType(Format.Native,
     IsByteOrdered = true,
     Name = "Point", ValidationMethodName = "ValidatePoint")]
public struct Point : INullable
{

備註

SQL Server 會建立系結至具有SqlUserDefinedTypeAttribute自定義屬性之型別定義的使用者定義型別。 每個 UDT 都必須以這個屬性標註。 如需 UDT 的詳細資訊,請參閱 CLR User-Defined 類型 ,包括 UDT 的範例。

建構函式

SqlUserDefinedTypeAttribute(Format)

使用者定義型別 (UDT) 上的必要屬性,用於確認指定的型別是 UDT,並指出 UDT 的儲存格式。

屬性

Format

序列化格式為 Format

IsByteOrdered

指出使用者定義型別是否依位元組排序。

IsFixedLength

指出這個使用者定義型別的所有執行個體 (Instance) 是否為同一長度。

MaxByteSize

執行個體的大小最大值 (位元組)。

Name

使用者定義型別的 SQL Server 名稱。

ValidationMethodName

方法的名稱,用於驗證使用者定義型別的執行個體。

適用於