Page 1 of 1

ORA : Character set mismatch

Posted: Thu 20 Feb 2020 09:31
by Velu
Hi,

We are using .netcore 3.1
and
Devart internal build https://download.devart.com/nuget_oracle_9_10_921.zip .

We have already shared the sample project with you. [39708]

After executing this query in LINQ we got Character set mismatch error.

Linq query
(from lst in _ControlfileRepository.GetAll()
select new ControlFileCORE()
{
COL_NAME = lst.COL_NAME == "" ? "" : lst.COL_NAME,
VALUE = lst.VALUE == "" ? "" : lst.VALUE,
Id = lst.Id
}).ToList();


Oracle Query generated by this LINQ query is:

SELECT CASE
WHEN c.COL_NAME IS NULL THEN N''
ELSE c.COL_NAME
END COL_NAME, CASE
WHEN c.VALUE IS NULL THEN N''
ELSE c.VALUE
END VALUE, c.Id
FROM CONTROLFILE c

How can we handle this?

[In the previous version of .net this is working fine]

Please help us to solve this issue.

Re: ORA : Character set mismatch

Posted: Wed 04 Mar 2020 09:10
by Velu
.netCore 3.1

To solve this issue temporarily. Add Entity framework interceptor like this

Code: Select all

 public class NVarcharInterceptor : DbCommandInterceptor
    {
        public override InterceptionResult<DbDataReader> ReaderExecuting(System.Data.Common.DbCommand dbCommand,
            Microsoft.EntityFrameworkCore.Diagnostics.CommandEventData eventData,
            Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<DbDataReader> result)
        {
            if (dbCommand.CommandText.Contains("N''"))
            {
                dbCommand.CommandText = dbCommand.CommandText.Replace("N''", "''");
            }

           return base.ReaderExecuting(dbCommand, eventData, result);
        }
    }



add this interceptor in

Code: Select all

DbContextOptionsBuilder<DbContext> builder

 builder.AddInterceptors(new NVarcharInterceptor())
 
This will solve the character set mismatch issue in EFCORE 3.1

Re: ORA : Character set mismatch

Posted: Thu 05 Mar 2020 14:49
by Shalex
Velu wrote: Thu 20 Feb 2020 09:31 Linq query
(from lst in _ControlfileRepository.GetAll()
select new ControlFileCORE()
{
COL_NAME = lst.COL_NAME == "" ? "" : lst.COL_NAME,
VALUE = lst.VALUE == "" ? "" : lst.VALUE,
Id = lst.Id
}).ToList();
There are no _ControlfileRepository variable and ControlFileCORE class in your DpSecureNSDLDemo test project. Please upload an updated test project to some file exchange server and send us the download link.