Oracle 在执行由 entity framework 6.0 生成的查询时抛出 ORA-00911 无效字符错误
Oracle throws ORA-00911 invalid character error while executing a query generated by entity framework 6.0
我在使用 Entity Framewrok 6.0 生成的以下查询时遇到问题。当我删除 where 子句时,查询执行得很好。但我看不到 where 子句的问题。你能帮我么?
{SELECT
"Extent1"."ID" AS "ID",
"Extent1"."STATECODE" AS "STATECODE",
"Extent1"."FIRMAID" AS "FIRMAID",
"Extent1"."ILID" AS "ILID",
"Extent1"."ILCEID" AS "ILCEID",
"Extent1"."PLANTURID" AS "PLANTURID",
"Extent1"."ETUDTURID" AS "ETUDTURID",
"Extent1"."ETUDAMACID" AS "ETUDAMACID",
"Extent1"."DILIMID" AS "DILIMID",
"Extent1"."ACIKLAMA" AS "ACIKLAMA",
"Extent1"."BASVURUTARIHI" AS "BASVURUTARIHI",
"Extent1"."ALAN" AS "ALAN",
"Extent1"."OLCEK" AS "OLCEK",
"Extent1"."CREATETIME" AS "CREATETIME",
"Extent1"."UPDATETIME" AS "UPDATETIME",
"Extent1"."CREATEUSERID" AS "CREATEUSERID",
"Extent1"."UPDATEUSERID" AS "UPDATEUSERID",
"Extent2"."ID" AS "ID1",
"Extent2"."KOD" AS "KOD",
"Extent2"."AD" AS "AD",
"Extent2"."CREATETIME" AS "CREATETIME1",
"Extent2"."UPDATETIME" AS "UPDATETIME1",
"Extent2"."CREATEUSERID" AS "CREATEUSERID1",
"Extent2"."UPDATEUSERID" AS "UPDATEUSERID1",
"Extent3"."ID" AS "ID2",
"Extent3"."KOD" AS "KOD1",
"Extent3"."AD" AS "AD1",
"Extent3"."PLANTURID" AS "PLANTURID1",
"Extent3"."CREATETIME" AS "CREATETIME2",
"Extent3"."UPDATETIME" AS "UPDATETIME2",
"Extent3"."CREATEUSERID" AS "CREATEUSERID2",
"Extent3"."UPDATEUSERID" AS "UPDATEUSERID2",
"Extent4"."ID" AS "ID3",
"Extent4"."VERGINUMARASI" AS "VERGINUMARASI",
"Extent4"."EMAIL" AS "EMAIL",
"Extent4"."FIRMAADI" AS "FIRMAADI",
"Extent4"."BUROTESCILNUMARASI" AS "BUROTESCILNUMARASI",
"Extent4"."TELEFON" AS "TELEFON",
"Extent4"."ADRES" AS "ADRES",
"Extent4"."ILID" AS "ILID1",
"Extent4"."ILCEID" AS "ILCEID1",
"Extent4"."MAHALLEID" AS "MAHALLEID",
"Extent4"."VERGIDAIRESIID" AS "VERGIDAIRESIID",
"Extent4"."USERID" AS "USERID",
"Extent4"."NODEID" AS "NODEID",
"Extent4"."CREATETIME" AS "CREATETIME3",
"Extent4"."UPDATETIME" AS "UPDATETIME3",
"Extent4"."CREATEUSERID" AS "CREATEUSERID3",
"Extent4"."UPDATEUSERID" AS "UPDATEUSERID3",
"Extent5"."FEATUREID" AS "FEATUREID",
"Extent5"."ADI_NUMARASI" AS "ADI_NUMARASI",
"Extent5"."UAVTKOD" AS "UAVTKOD",
"Extent6"."FEATUREID" AS "FEATUREID1",
"Extent6"."ADI_NUMARASI" AS "ADI_NUMARASI1",
"Extent6"."UAVTKOD" AS "UAVTKOD1",
"Extent6"."ILKOD" AS "ILKOD",
"Extent7"."ID" AS "ID4",
"Extent7"."ENLEM" AS "ENLEM",
"Extent7"."BOYLAM" AS "BOYLAM",
"Extent7"."DILIMI" AS "DILIMI",
"Extent7"."MERIDYEN" AS "MERIDYEN",
"Extent7"."ILADI" AS "ILADI",
"Extent7"."ILID" AS "ILID2",
"Extent8"."ID" AS "ID5",
"Extent8"."KOD" AS "KOD2",
"Extent8"."AD" AS "AD2",
"Extent8"."CREATETIME" AS "CREATETIME4",
"Extent8"."UPDATETIME" AS "UPDATETIME4",
"Extent8"."CREATEUSERID" AS "CREATEUSERID4",
"Extent8"."UPDATEUSERID" AS "UPDATEUSERID4"
FROM "JEOLOJI"."PROJE" "Extent1"
INNER JOIN "JEOLOJI"."ETUDAMAC" "Extent2" ON "Extent1"."ETUDAMACID" = "Extent2"."ID"
INNER JOIN "JEOLOJI"."ETUDTUR" "Extent3" ON "Extent1"."ETUDTURID" = "Extent3"."ID"
INNER JOIN "JEOLOJI"."FIRMA" "Extent4" ON "Extent1"."FIRMAID" = "Extent4"."ID"
INNER JOIN "JEOLOJI"."IL" "Extent5" ON "Extent1"."ILID" = "Extent5"."FEATUREID"
LEFT OUTER JOIN "JEOLOJI"."ILCE" "Extent6" ON "Extent1"."ILCEID" = "Extent6"."FEATUREID"
INNER JOIN "JEOLOJI"."DILIM" "Extent7" ON "Extent1"."DILIMID" = "Extent7"."ID"
INNER JOIN "JEOLOJI"."PLANTUR" "Extent8" ON "Extent1"."PLANTURID" = "Extent8"."ID"
WHERE ((1 = (CASE WHEN (( NVL(INSTR(LOWER(CASE WHEN ("Extent1"."ACIKLAMA" IS NULL) THEN '' ELSE "Extent1"."ACIKLAMA" END), LOWER('Ma')), 0) ) = 1) THEN 1 WHEN (( NVL(INSTR(LOWER(CASE WHEN ("Extent1"."ACIKLAMA" IS NULL) THEN '' ELSE "Extent1"."ACIKLAMA" END), LOWER('Ma')), 0) ) <> 1) THEN 0 END)) AND (22 <> "Extent1"."FIRMAID"))}
我解决了问题。
我们在 c# 中用 StringLength
属性标记我们的 string
类型,以防止 Entity Framework 在 Oracle 上将它们创建为 NCLOB
列。然后 Entity Framework 为标有 StringLenth
属性的 c# 属性生成类型为 nvarchar
的列。
在这个查询中,where
子句由于 qoutes 而与 varchar2
一起工作(正如我从我的 Db 专业朋友那里了解到的那样。)所以我更改了列的类型并解决了。
我在使用 Entity Framewrok 6.0 生成的以下查询时遇到问题。当我删除 where 子句时,查询执行得很好。但我看不到 where 子句的问题。你能帮我么?
{SELECT
"Extent1"."ID" AS "ID",
"Extent1"."STATECODE" AS "STATECODE",
"Extent1"."FIRMAID" AS "FIRMAID",
"Extent1"."ILID" AS "ILID",
"Extent1"."ILCEID" AS "ILCEID",
"Extent1"."PLANTURID" AS "PLANTURID",
"Extent1"."ETUDTURID" AS "ETUDTURID",
"Extent1"."ETUDAMACID" AS "ETUDAMACID",
"Extent1"."DILIMID" AS "DILIMID",
"Extent1"."ACIKLAMA" AS "ACIKLAMA",
"Extent1"."BASVURUTARIHI" AS "BASVURUTARIHI",
"Extent1"."ALAN" AS "ALAN",
"Extent1"."OLCEK" AS "OLCEK",
"Extent1"."CREATETIME" AS "CREATETIME",
"Extent1"."UPDATETIME" AS "UPDATETIME",
"Extent1"."CREATEUSERID" AS "CREATEUSERID",
"Extent1"."UPDATEUSERID" AS "UPDATEUSERID",
"Extent2"."ID" AS "ID1",
"Extent2"."KOD" AS "KOD",
"Extent2"."AD" AS "AD",
"Extent2"."CREATETIME" AS "CREATETIME1",
"Extent2"."UPDATETIME" AS "UPDATETIME1",
"Extent2"."CREATEUSERID" AS "CREATEUSERID1",
"Extent2"."UPDATEUSERID" AS "UPDATEUSERID1",
"Extent3"."ID" AS "ID2",
"Extent3"."KOD" AS "KOD1",
"Extent3"."AD" AS "AD1",
"Extent3"."PLANTURID" AS "PLANTURID1",
"Extent3"."CREATETIME" AS "CREATETIME2",
"Extent3"."UPDATETIME" AS "UPDATETIME2",
"Extent3"."CREATEUSERID" AS "CREATEUSERID2",
"Extent3"."UPDATEUSERID" AS "UPDATEUSERID2",
"Extent4"."ID" AS "ID3",
"Extent4"."VERGINUMARASI" AS "VERGINUMARASI",
"Extent4"."EMAIL" AS "EMAIL",
"Extent4"."FIRMAADI" AS "FIRMAADI",
"Extent4"."BUROTESCILNUMARASI" AS "BUROTESCILNUMARASI",
"Extent4"."TELEFON" AS "TELEFON",
"Extent4"."ADRES" AS "ADRES",
"Extent4"."ILID" AS "ILID1",
"Extent4"."ILCEID" AS "ILCEID1",
"Extent4"."MAHALLEID" AS "MAHALLEID",
"Extent4"."VERGIDAIRESIID" AS "VERGIDAIRESIID",
"Extent4"."USERID" AS "USERID",
"Extent4"."NODEID" AS "NODEID",
"Extent4"."CREATETIME" AS "CREATETIME3",
"Extent4"."UPDATETIME" AS "UPDATETIME3",
"Extent4"."CREATEUSERID" AS "CREATEUSERID3",
"Extent4"."UPDATEUSERID" AS "UPDATEUSERID3",
"Extent5"."FEATUREID" AS "FEATUREID",
"Extent5"."ADI_NUMARASI" AS "ADI_NUMARASI",
"Extent5"."UAVTKOD" AS "UAVTKOD",
"Extent6"."FEATUREID" AS "FEATUREID1",
"Extent6"."ADI_NUMARASI" AS "ADI_NUMARASI1",
"Extent6"."UAVTKOD" AS "UAVTKOD1",
"Extent6"."ILKOD" AS "ILKOD",
"Extent7"."ID" AS "ID4",
"Extent7"."ENLEM" AS "ENLEM",
"Extent7"."BOYLAM" AS "BOYLAM",
"Extent7"."DILIMI" AS "DILIMI",
"Extent7"."MERIDYEN" AS "MERIDYEN",
"Extent7"."ILADI" AS "ILADI",
"Extent7"."ILID" AS "ILID2",
"Extent8"."ID" AS "ID5",
"Extent8"."KOD" AS "KOD2",
"Extent8"."AD" AS "AD2",
"Extent8"."CREATETIME" AS "CREATETIME4",
"Extent8"."UPDATETIME" AS "UPDATETIME4",
"Extent8"."CREATEUSERID" AS "CREATEUSERID4",
"Extent8"."UPDATEUSERID" AS "UPDATEUSERID4"
FROM "JEOLOJI"."PROJE" "Extent1"
INNER JOIN "JEOLOJI"."ETUDAMAC" "Extent2" ON "Extent1"."ETUDAMACID" = "Extent2"."ID"
INNER JOIN "JEOLOJI"."ETUDTUR" "Extent3" ON "Extent1"."ETUDTURID" = "Extent3"."ID"
INNER JOIN "JEOLOJI"."FIRMA" "Extent4" ON "Extent1"."FIRMAID" = "Extent4"."ID"
INNER JOIN "JEOLOJI"."IL" "Extent5" ON "Extent1"."ILID" = "Extent5"."FEATUREID"
LEFT OUTER JOIN "JEOLOJI"."ILCE" "Extent6" ON "Extent1"."ILCEID" = "Extent6"."FEATUREID"
INNER JOIN "JEOLOJI"."DILIM" "Extent7" ON "Extent1"."DILIMID" = "Extent7"."ID"
INNER JOIN "JEOLOJI"."PLANTUR" "Extent8" ON "Extent1"."PLANTURID" = "Extent8"."ID"
WHERE ((1 = (CASE WHEN (( NVL(INSTR(LOWER(CASE WHEN ("Extent1"."ACIKLAMA" IS NULL) THEN '' ELSE "Extent1"."ACIKLAMA" END), LOWER('Ma')), 0) ) = 1) THEN 1 WHEN (( NVL(INSTR(LOWER(CASE WHEN ("Extent1"."ACIKLAMA" IS NULL) THEN '' ELSE "Extent1"."ACIKLAMA" END), LOWER('Ma')), 0) ) <> 1) THEN 0 END)) AND (22 <> "Extent1"."FIRMAID"))}
我解决了问题。
我们在 c# 中用 StringLength
属性标记我们的 string
类型,以防止 Entity Framework 在 Oracle 上将它们创建为 NCLOB
列。然后 Entity Framework 为标有 StringLenth
属性的 c# 属性生成类型为 nvarchar
的列。
在这个查询中,where
子句由于 qoutes 而与 varchar2
一起工作(正如我从我的 Db 专业朋友那里了解到的那样。)所以我更改了列的类型并解决了。