Skip to content

Add ADO.NET support for Utf8String #28966

@bgrainger

Description

@bgrainger

Utf8String is being added to .NET: #933 dotnet/corefx#35989

There may be opportunities to use this type in the ADO.NET API, particularly for database protocols/providers that use UTF-8 on the wire.

The most obvious enhancement seems like:

public abstract class DbDataReader
{
    public virtual Utf8String GetUtf8String(int ordinal) => new Utf8String(GetString(ordinal));
    public virtual Utf8String GetUtf8String(string name) => GetUtf8String(GetOrdinal(name));
}

Perhaps less realistically, a new DbCommand.CommandTextUtf8 property could be added, which would be preferred over DbCommand.CommandText if it were set.

public abstract class DbCommand
{
    public virtual Utf8String CommandTextUtf8
    {
        get => CommandText is null ? null : new Utf8String(CommandText);
        set => CommandText = value?.ToString();
    }
}

Finally, implementations should be encouraged to support an Utf8String as the value of DbParameter.Value.

Are there any other opportunities or easy wins?

Related: #28135, mysql-net/MySqlConnector#618

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions