简体   繁体   English

实体框架无法连接Oracle中的Enum列

[英]Entity Framework cannot concat Enum column in Oracle

Im using EntityFramework 6.1 with Oracle, I need to write the query to concatenate two columns in where predict expression. 我将EntityFramework 6.1与Oracle一起使用时,我需要编写查询以在预测表达式的地方串联两列。

I used the below code: 我用下面的代码:

/* t.Col1 : string , t.Col2: Enum */
db.Table1.Where(t => t.Col1 + " " + t.Col2 == "SomeValue");

But I get the OracleException: ORA-12704: character set mismatch error. 但是我得到了OracleException:ORA-12704:字符集不匹配错误。 I want to apply the condition before fetch the data from Database. 我想在从数据库中获取数据之前应用条件。 So anyone has idea how can I handle this issue? 因此,有人知道我该如何处理这个问题?

I already saw this topic , but that solution doesn't work if one of the column be Enum. 我已经看到了这个主题 ,但是如果其中一个列是Enum,则该解决方案将不起作用。

I've checked the commandtext and found try to convert empty char to NCLOB 我检查了命令文本,发现尝试将空字符转换为NCLOB

THEN N'' ELSE TO_NCLOB

So I updated the @solidau answer with following solution: 所以我用以下解决方案更新了@solidau答案:

command.CommandText = command.CommandText.Replace("N''", "''").Replace("THEN '' ELSE TO_NCLOB", "THEN N'' ELSE TO_NCHAR");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM