Skip to content

Commit

Permalink
Enhancing the SqlDbType with Json (#103985)
Browse files Browse the repository at this point in the history
Closes #103925
  • Loading branch information
saurabh500 authored Jul 11, 2024
1 parent 0d426df commit 2fe4afa
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/libraries/System.Data.Common/ref/System.Data.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,7 @@ public enum SqlDbType
Time = 32,
DateTime2 = 33,
DateTimeOffset = 34,
Json = 35,
}
public sealed partial class StateChangeEventArgs : System.EventArgs
{
Expand Down
149 changes: 147 additions & 2 deletions src/libraries/System.Data.Common/src/System/Data/SqlDbType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,185 @@

namespace System.Data
{
// Specifies the SQL Server data type.
/// <summary>
/// Specifies SQL Server-specific data type of a field, property, for use in a <see cref="T:Microsoft.Data.SqlClient.SqlParameter" />.
/// </summary>
public enum SqlDbType
{
// A 64-bit signed integer.
/// <summary>
/// <see cref="long" />. A 64-bit signed integer.
/// </summary>
BigInt = 0,

/// <summary>
/// <see cref="Array"/> of type <see cref="byte"/>. A fixed-length stream of binary data ranging between 1 and 8,000 bytes.
/// </summary>
Binary = 1,

/// <summary>
/// <see cref="bool"/>. An unsigned numeric value that can be 0, 1, or <see langword="null"/>
/// </summary>
Bit = 2,

/// <summary>
/// <see cref="string"/>. A fixed-length stream of non-Unicode characters ranging between 1 and 8,000 characters.
/// </summary>
Char = 3,

/// <summary>
/// <see cref="System.DateTime"/>. Date and time data ranging in value from January 1, 1753 to December 31, 9999 to an accuracy of 3.33 milliseconds
/// </summary>
DateTime = 4,

/// <summary>
/// <see cref="decimal"/>. A fixed precision and scale numeric value between -10 <sup>38</sup> -1 and 10 <sup>38</sup> -1.
/// </summary>
Decimal = 5,

/// <summary>
/// <see cref="double"/>. A floating point number within the range of -1.79E +308 through 1.79E +308.
/// </summary>
Float = 6,

/// <summary>
/// <see cref="Array"/> of type <see cref="byte"/>. A variable-length stream of binary data ranging from 0 to 2 <sup>31</sup> -1
/// (or 2,147,483,647) bytes.
/// </summary>
Image = 7,

/// <summary>
/// <see cref="int"/>. A 32-bit signed integer.
/// </summary>
Int = 8,

/// <summary>
/// <see cref="decimal"/>. A currency value ranging from -2 <sup>63</sup> (or -9,223,372,036,854,775,808) to 2 <sup>63</sup>
/// -1 (or +9,223,372,036,854,775,807) with an accuracy to a ten-thousandth of a currency unit.
/// </summary>
Money = 9,

/// <summary>
/// <see cref="string"/>. A fixed-length stream of Unicode characters ranging between 1 and 4,000 characters.
/// </summary>
NChar = 10,

/// <summary>
/// <see cref="string"/>. A variable-length stream of Unicode data with a maximum length of 2 <sup>30</sup> - 1
/// (or 1,073,741,823) characters.
/// </summary>
NText = 11,

/// <summary>
/// <see cref="string"/>. A variable-length stream of Unicode characters ranging between 1 and 4,000 characters. Implicit
/// conversion fails if the string is greater than 4,000 characters. Explicitly set the object when working with strings
/// longer than 4,000 characters. Use <see cref="F:System.Data.SqlDbType.NVarChar"/> when the database column is
/// <see langword="nvarchar(max)"/>.
/// </summary>
NVarChar = 12,

/// <summary>
/// <see cref="float"/>. A floating point number within the range of -3.40E +38 through 3.40E +38.
/// </summary>
Real = 13,

/// <summary>
/// <see cref="Guid"/>. A globally unique identifier (or GUID).
/// </summary>
UniqueIdentifier = 14,

/// <summary>
/// <see cref="System.DateTime"/>. Date and time data ranging in value from January 1, 1900 to June 6, 2079 to an accuracy of one minute.
/// </summary>
SmallDateTime = 15,

/// <summary>
/// <see cref="short"/>. A 16-bit signed integer.
/// </summary>
SmallInt = 16,

/// <summary>
/// <see cref="decimal"/>. A currency value ranging from -214,748.3648 to +214,748.3647 with an accuracy to a ten-thousandth of a currency unit.
/// </summary>
SmallMoney = 17,

/// <summary>
/// <see cref="string"/>. A variable-length stream of non-Unicode data with a maximum length of 2 <sup>31</sup> -1 (or 2,147,483,647) characters.
/// </summary>
Text = 18,

/// <summary>
/// <see cref="System.Array"/> of type <see cref="byte"/>. Automatically generated binary numbers, which are guaranteed to be unique within a database. <see langword="timestamp"/> is used typically as a mechanism for version-stamping table rows. The storage size is 8 bytes.
/// </summary>
Timestamp = 19,

/// <summary>
/// <see cref="byte"/>. An 8-bit unsigned integer.
/// </summary>
TinyInt = 20,

/// <summary>
/// <see cref="System.Array"/> of type <see cref="byte"/>. A variable-length stream of binary data ranging between 1 and 8,000 bytes.
/// Implicit conversion fails if the byte array is greater than 8,000 bytes. Explicitly set the object when working with byte arrays
/// larger than 8,000 bytes.
/// </summary>
VarBinary = 21,

/// <summary>
/// <see cref="string"/>. A variable-length stream of non-Unicode characters ranging between 1 and 8,000 characters.
/// Use <see cref="F:System.Data.SqlDbType.VarChar"/> when the database column is <see langword="varchar(max)"/>.
/// </summary>
VarChar = 22,

/// <summary>
/// <see cref="object"/>. A special data type that can contain numeric, string, binary, or date data as well as the SQL Server values Empty and Null,
/// which is assumed if no other type is declared.
/// </summary>
Variant = 23,

/// <summary>
/// An XML value. Obtain the XML as a string using the <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.GetValue(System.Int32)"/> method or
/// <see cref="P:System.Data.SqlTypes.SqlXml.Value"/> property, or as an <see cref="T:System.Xml.XmlReader"/> by calling the
/// <see cref="M:System.Data.SqlTypes.SqlXml.CreateReader"/> method.
/// </summary>
Xml = 25,

/// <summary>
/// A SQL Server user-defined type (UDT).
/// </summary>
Udt = 29,

/// <summary>
/// A special data type for specifying structured data contained in table-valued parameters.
/// </summary>
Structured = 30,

/// <summary>
/// Date data ranging in value from January 1,1 AD through December 31, 9999 AD.
/// </summary>
Date = 31,

/// <summary>
/// Time data based on a 24-hour clock. Time value range is 00:00:00 through 23:59:59.9999999 with an accuracy of 100 nanoseconds.
/// Corresponds to a SQL Server <see langword="time"/> value.
/// </summary>
Time = 32,

/// <summary>
/// Date and time data. Date value range is from January 1,1 AD through December 31, 9999 AD.
/// Time value range is 00:00:00 through 23:59:59.9999999 with an accuracy of 100 nanoseconds.
/// </summary>
DateTime2 = 33,

/// <summary>
/// Date and time data with time zone awareness. Date value range is from January 1,1 AD through December 31, 9999 AD.
/// Time value range is 00:00:00 through 23:59:59.9999999 with an accuracy of 100 nanoseconds. Time zone value range
/// is -14:00 through +14:00.
/// </summary>
DateTimeOffset = 34,

/// <summary>
/// A JSON value.
/// </summary>
Json = 35,
}
}

0 comments on commit 2fe4afa

Please sign in to comment.