Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Json in SqlDbType #103925

Closed
Tracked by #2622
saurabh500 opened this issue Jun 24, 2024 · 4 comments · Fixed by #103985
Closed
Tracked by #2622

Expose Json in SqlDbType #103925

saurabh500 opened this issue Jun 24, 2024 · 4 comments · Fixed by #103985
Assignees
Labels
api-approved API was approved in API review, it can be implemented area-System.Data.SqlClient
Milestone

Comments

@saurabh500
Copy link
Contributor

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

@saurabh500 saurabh500 added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Jun 24, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jun 24, 2024
Copy link
Contributor

Tagging subscribers to this area: @DavoudEshtehari, @David-Engel, @JRahnama
See info in area-owners.md if you want to be subscribed.

@saurabh500
Copy link
Contributor Author

@roji roji removed the untriaged New issue has not been triaged by the area owner label Jun 25, 2024
@roji
Copy link
Member

roji commented Jun 25, 2024

Thanks. Just noting that SqlDbType isn't actually referenced anywhere inside the runtime libraries, and @saurabh500 confirmed that previous versions of SqlClient are confirmed to throw on unknown SqlDbType values, so if a user attempts to use the new SqlDbType.Json with an older SqlClient, we should be safe there.

@roji roji added api-ready-for-review API is ready for review, it is NOT ready for implementation and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Jun 25, 2024
@roji roji added this to the 9.0.0 milestone Jun 25, 2024
@roji roji self-assigned this Jun 25, 2024
@roji roji added the blocking Marks issues that we want to fast track in order to unblock other important work label Jul 8, 2024
@bartonjs
Copy link
Member

bartonjs commented Jul 9, 2024

Video

Looks good as proposed

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

@bartonjs bartonjs added api-approved API was approved in API review, it can be implemented and removed blocking Marks issues that we want to fast track in order to unblock other important work api-ready-for-review API is ready for review, it is NOT ready for implementation labels Jul 9, 2024
@roji roji closed this as completed in 2fe4afa Jul 11, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-System.Data.SqlClient
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants