dotnet-db-samples icon indicating copy to clipboard operation
dotnet-db-samples copied to clipboard

Unicode conversion default behaviour. Not changeable when using string interpolated queries.

Open BernhardNinaus opened this issue 1 year ago • 1 comments

It is not possible to change the default string conversion (nvarchar2) in an interpolated string.

e.g.

 db.Model.FromSqlInterpolated("select ... from ... where key in (... field = {val} ...)")

What I already considered:

  • https://docs.oracle.com/en/database/oracle/oracle-database/21/odpnt/EFCorePerformanceConsiderations.html#GUID-E12B036C-A8B7-4891-9713-B079AC4815DD

Note that field is not accessible in Model.

It would be really nice to globaly change the behaviour of using varchar2 instead of nvarchar2. Something like:

builder.Services.AddDbContext<DataContext>(
    options => options.UseOracle(builder.Configuration.GetConnectionString("DB"),
    oraOptionsBuilder => oraOptionsBuilder.UserVarchar2()));

This would also allow to be a little more lazy on the column type definition with HasColumnType.

BernhardNinaus avatar May 02 '23 06:05 BernhardNinaus

There aren't any current workarounds, I can think of. I've filed an enhancement request (ER 35359392) to track this issue.

alexkeh avatar May 04 '23 15:05 alexkeh