Export (0) Print
Expand All

Format Enumeration

Used by SqlUserDefinedTypeAttribute and SqlUserDefinedAggregateAttribute to indicate the serialization format of a user-defined type (UDT) or aggregate.

Namespace:  Microsoft.SqlServer.Server
Assembly:  System.Data (in System.Data.dll)

public enum Format

Member nameDescription
NativeThe Native serialization format uses a very simple algorithm that enables SQL Server to store an efficient representation of the UDT on disk. Types marked for Native serialization can only have value types (structs in Microsoft Visual C# and structures in Microsoft Visual Basic .NET) as members. Members of reference types (such as classes in Visual C# and Visual Basic), either user-defined or those existing in the framework (such as String), are not supported.

The requirements for this format are:

  • The StructLayout.LayoutKindSequential attribute must be applied to the aggregate or UDT if it is defined in a class and not a structure. This controls the physical layout of the data fields, and is used to force the members to be laid out sequentially in the order they appear. SQL Server uses this attribute to determine the field order for UDTs with multiple fields.

  • The type must contain at least one member (serialized values cannot be zero bytes in size).

  • All the fields of the aggregate must be blittable, that is, they must have a common representation in both managed and unmanaged memory and not require special handling by the interop marshaler.

  • All the fields of the UDT should be of one of the following types that can be serialized: bool, byte,sbyte,short,ushort, int, uint, long, ulong, float, double, SqlByte, SqlInt16, SqlInt32, SqlInt64, SqlDateTime, SqlSingle, SqlDouble, SqlMoney, or other value types defined by the user that contain fields of one of these types.

  • The aggregate must not specify a value for MaxByteSize.

  • The aggregate must not have any [NonSerialized] fields.

  • Fields must not be marked as an explicit layout (StructLayoutAttribute).

UnknownThe serialization format is unknown.
UserDefinedThe UserDefined serialization format gives the developer full control over the binary format through the IBinarySerialize.Write and IBinarySerialize.Read methods.

The aggregate must specify a value for MaxByteSize.

Specify the IsByteOrdered attribute property. The default value is false.

If you omit any field in the Read or Write methods, the state of that field is not serialized.

Used by SqlUserDefinedTypeAttribute and SqlUserDefinedAggregateAttribute to indicate the serialization format of a user-defined type (UDT) or aggregate.

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.

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

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft