Skip to content

Expose Json in SqlDbType #103925

@saurabh500

Description

@saurabh500

Background and motivation

The System.Data.SqlDbType enum represents the datatypes supported by SQL Server and is used with SqlParameter to specify the column type to be used in SQL server operations while execution SqlCommand.

With the JSON datatype being supported in SQL Server link There is a need to support the JSON type in Microsoft.Data.SqlClient ADO.Net provider for SQL Server.

The API suggestion is aimed at adding an enum called Json with value 35 in SqlDbType.
Once this enum is available Microsoft.Data.SqlClient (the SQL Server driver) can then leverage the enum value to allow JSON operations using Microsoft.Data.SqlClient APIs.

namespace System.Data
{
    // Specifies the SQL Server data type.
    public enum SqlDbType
    {
        Json = 35,
    }
}

The version of Microsoft.Data.SqlClient targeting .Net 9, will be able to use the enum SqlDbType.Json to provide JSON support.

API Proposal

namespace System.Data
{
    // Specifies the SQL Server data type.
    public enum SqlDbType
    {
        Json = 35,
    }
}

API Usage

using Microsoft.Data.SqlClient;


SqlParameter param = new SqlParameter();

param.SqlDbType = System.Data.SqlDbType.Json;

There are parameters / properties in the constructors and APIs, which will be enhanced to support SqlDbType.Json

SqlParameter
SqlParameterCollection
SqlMetaData

Alternative Designs

No response

Risks

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions