【问题标题】:Entity Framework cannot concat Enum column in Oracle实体框架无法连接 Oracle 中的枚举列
【发布时间】:2017-05-04 07:03:44
【问题描述】:

我在 Oracle 中使用 EntityFramework 6.1,我需要编写查询来连接 where predict 表达式中的两列。

我使用了以下代码:

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

但我得到了 OracleException: ORA-12704: character set mismatch 错误。我想在从数据库中获取数据之前应用条件。那么有人知道我该如何处理这个问题吗?

我已经看到了这个topic,但是如果其中一列是 Enum,那么该解决方案将不起作用。

【问题讨论】:

  • 您可以手写查询吗?像这样:db.Table1.SqlQuery(...)

标签: c# oracle entity-framework-6


【解决方案1】:

我检查了命令文本,发现尝试将空字符转换为 NCLOB

THEN N'' ELSE TO_NCLOB

所以我用以下解决方案更新了@solidau 答案:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多