<PackageReference Include="Microsoft.Data.SqlClient" Version="7.0.0-preview2.25289.6" />

Microsoft.Data.SqlClient.Packet

sealed class Packet
Contains a buffer for a partial or full packet and methods to get information about the status of the packet that the buffer represents. This class is used to contain partial packet data and helps ensure that the packet data is completely received before a full packet is made available to the rest of the library
public const int UnknownDataLength = -1

public byte[] Buffer { get; set; }

A byte array containing CurrentLength bytes of data

public bool ContainsCompletePacket { get; }

returns a boolean value indicating whether the Buffer contains enough data for a valid tds header, has a DataLength set and that the CurrentLength is greater than or equal to the DataLength + tds header length.

public int CurrentLength { get; set; }

The total count of bytes currently in the Buffer array including the tds header bytes

public int DataLength { get; set; }

If the packet data has enough bytes available to determine the amount of data that should be present in the packet then this property will be set to the count of data bytes in the packet, otherwise this will be -1

public bool HasDataLength { get; }

returns a boolean value indicating if the DataLength value has been set.

public bool HasHeader { get; }

returns a boolean value indicating if there are enough total bytes available in the Buffer to read the tds header

public int RequiredLength { get; }

If the packet data has enough bytes available to determine the length amount of data that should be present in the packet then this property will return the count of data bytes that are expected to be in the packet. If there are not enough bytes to determine the data byte count then this property will throw an exception. Call HasDataLength to check if there will be a value before using this property.

public Packet()

public static void ThrowDisposed()

public ReadOnlySpan<byte> GetHeaderSpan()

returns a containing the first 8 bytes of the Buffer array which will contain the TDS header bytes. This can be passed to static functions on Packet to extract information from the tds packet header. Call HasHeader before using this function.