I am currently using Oracle Managed Driver (v12.1.2400) as my Entity Framework driver and currently see ORA-12704: character set mismatch error at runtime.
The LINQ-> SQL code that I'm using looks like this:
from c in CUSTOMER.AsNoTracking() where c.ACCOUNT.Contains("DE") && c.DELETED == "N" orderby (c.FORENAME + c.SURNAME) select new { c.ACCOUNT, c.FORENAME, c.SURNAME})
and this creates the following SQL:
SELECT "Project1"."C2" AS "C1", "Project1"."ACCOUNT" AS "ACCOUNT", "Project1"."FORENAME" AS "FORENAME", "Project1"."SURNAME" AS "SURNAME" FROM ( SELECT( (CASE WHEN ("Extent1"."FORENAME" IS NULL) THEN N'' ELSE "Extent1"."FORENAME" END) ||(CASE WHEN ("Extent1"."SURNAME" IS NULL) THEN N'' ELSE "Extent1"."SURNAME" END)) AS "C1", "Extent1"."ACCOUNT" AS "ACCOUNT", "Extent1"."FORENAME" AS "FORENAME", "Extent1"."SURNAME" AS "SURNAME", 1 AS "C2" FROM "TEST"."CUSTOMER" "Extent1" WHERE (("Extent1"."ACCOUNT" LIKE '%DE%') AND ('N' = "Extent1"."DELETED"))) "Project1" ORDER BY "Project1"."C1" ASC;
When I debug this SQL, I see that the problem is that SQL uses N'' in CASE sections. Since these columns are not Unicode, if I delete the previous N to leave only '' , then sql works as expected.
Can this be prevented by default?
All db columns are currently VARCHAR and modeled in C # as string .
The first code mappings for the two columns are as follows:
this.Property(t => t.FORENAME).HasColumnName("FORENAME").IsUnicode(false).HasMaxLength(35); this.Property(t => t.SURNAME).HasColumnName("SURNAME").IsUnicode(false).HasMaxLength(35);
I expected the IsUnicode(false) statement to take care of this.
FYI, this worked when I used EF5 and an unmanaged driver.
Also, the Devart dotConnectForOracle drivers do not have this problem, so I think this is a bug in the Oracle drivers.