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
Utf8Stringis being added to .NET: #933 dotnet/corefx#35989There 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:
Perhaps less realistically, a new
DbCommand.CommandTextUtf8property could be added, which would be preferred overDbCommand.CommandTextif it were set.Finally, implementations should be encouraged to support an
Utf8Stringas the value ofDbParameter.Value.Are there any other opportunities or easy wins?
Related: #28135, mysql-net/MySqlConnector#618