Dela via


SqlUserDefinedTypeAttribute Class

Definition

Used to mark a type definition in an assembly as a user-defined type (UDT) in 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
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct, AllowMultiple=false, Inherited=true)>]
type SqlUserDefinedTypeAttribute = class
    inherit Attribute
Public NotInheritable Class SqlUserDefinedTypeAttribute
Inherits Attribute
Inheritance
SqlUserDefinedTypeAttribute
Attributes

Examples

The following example shows the UserDefinedType attribute of the Point UDT. The UDT is byte-ordered, is named "Point", has a validation method named "ValidatePoint", and uses the native serialization format.

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
{

Remarks

SQL Server creates a user-defined type that is bound to the type definition that has the SqlUserDefinedTypeAttribute custom attribute. Every UDT must be annotated with this attribute. See CLR User-Defined Types for more information about UDTs, including an example of a UDT.

Constructors

SqlUserDefinedTypeAttribute(Format)

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.

Properties

Format

The serialization format as a Format .

IsByteOrdered

Indicates whether the user-defined type is byte ordered.

IsFixedLength

Indicates whether all instances of this user-defined type are the same length.

MaxByteSize

The maximum size of the instance, in bytes.

Name

The SQL Server name of the user-defined type.

ValidationMethodName

The name of the method used to validate instances of the user-defined type.

Applies to