Saya akhirnya mendapatkan penulis ini (ODP.Net Managed Driver - ORA-12704:ketidakcocokan set karakter dalam kode yang dihasilkan) untuk memperbarui pertanyaan, dia memposting solusi menggunakan interseptor, saya akan membahas lebih detail di sini .. .
Pertama, saya mendekorasi DBContext saya untuk memuat konfigurasi. Anda dapat melewati ini dan tambahkan saja ke konfigurasi Anda jika ada:
[DbConfigurationType(typeof(MyDbConfiguration))]
public partial class MyContext : DbContext
Buat kelas konfigurasi:
public class MyDbConfiguration : DbConfiguration
{
public MyDbConfiguration()
{
this.AddInterceptor(new NVarcharInterceptor()); //add this line to existing config.
}
}
Selanjutnya, buat pencegat:
public class NVarcharInterceptor : IDbCommandInterceptor
{
public void NonQueryExecuted(DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
{
if (command != null && !string.IsNullOrWhiteSpace(command.CommandText))
command.CommandText = command.CommandText.Replace("N''", "''");
}
public void NonQueryExecuting(DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
{
if (command != null && !string.IsNullOrWhiteSpace(command.CommandText))
command.CommandText = command.CommandText.Replace("N''", "''");
}
public void ReaderExecuted(DbCommand command, DbCommandInterceptionContext<DbDataReader> interceptionContext)
{
if (command != null && !string.IsNullOrWhiteSpace(command.CommandText))
command.CommandText = command.CommandText.Replace("N''", "''");
}
public void ReaderExecuting(DbCommand command, DbCommandInterceptionContext<DbDataReader> interceptionContext)
{
if (command != null && !string.IsNullOrWhiteSpace(command.CommandText))
command.CommandText = command.CommandText.Replace("N''", "''");
}
public void ScalarExecuted(DbCommand command, DbCommandInterceptionContext<object> interceptionContext)
{
if (command != null && !string.IsNullOrWhiteSpace(command.CommandText))
command.CommandText = command.CommandText.Replace("N''", "''");
}
public void ScalarExecuting(DbCommand command, DbCommandInterceptionContext<object> interceptionContext)
{
if (command != null && !string.IsNullOrWhiteSpace(command.CommandText))
command.CommandText = command.CommandText.Replace("N''", "''");
}
}