- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我试图在 Oracle 的 EF 中组合几列,然后像这样对这些列执行 .Contains()
:
public IEnumerable<User> SearchUsers(string search)
{
search = search.ToLower();
return _securityUow.Users
.Where(u => (u.FirstName.ToLower() + " " + u.LastName.ToLower() + " (" + u.NetId.ToLower() + ")").Contains(search))
.OrderBy(u => u.LastName)
.ThenBy(u => u.FirstName)
.AsEnumerable();
}
但是,我遇到了这个异常:
{
"Message": "An error has occurred.",
"ExceptionMessage": "An error occurred while executing the command definition. See the inner exception for details.",
"ExceptionType": "System.Data.Entity.Core.EntityCommandExecutionException",
"StackTrace": " at SoftwareRegistration.WebUI.Controllers.Api.V1.UserContactController.Lookup(String search) in C:\LocalRepository\OnlineSupport\SoftwareRegistration\trunk\release\SoftwareRegistration\SoftwareRegistration.WebUI\Controllers\Api\V1\UserContactController.cs:line 40\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "ORA-12704: character set mismatch",
"ExceptionType": "Oracle.ManagedDataAccess.Client.OracleException",
"StackTrace": " at OracleInternal.ServiceObjects.OracleCommandImpl.VerifyExecution(OracleConnectionImpl connectionImpl, Int32& cursorId, Boolean bThrowArrayBindRelatedErrors, OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone)\r\n at OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteReader(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, OracleDataReaderImpl& rdrImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[] scnForExecution, Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, Boolean& bBindParamPresent, Int64& internalInitialLOBFS, OracleException& exceptionForArrayBindDML, Boolean isDescribeOnly, Boolean isFromEF)\r\n at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)\r\n at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)\r\n at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\r\n at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)\r\n at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)\r\n at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)\r\n at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)\r\n at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\r\n at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)"
}
}
我正在查询的列在 Oracle 中都是 VARCHAR2(128) 类型。
我也在另一个项目中使用了完全相同的代码并且它有效。唯一的区别是,对于有效的项目,我使用 Oracle.DataAccess
,对于无效的项目,我使用 Oracle.ManagedDataAccess
(我我无法为此项目使用 Oracle.DataAccess
)。所以我相信托管驱动程序中存在错误/问题。
我愿意接受解决方案或变通办法。
最佳答案
我最终让这个 ( ODP.Net Managed Driver - ORA-12704: character set mismatch in generated code ) 的作者更新了这个问题,他发布了一个使用拦截器的解决方法,我将在这里详细介绍一下......
首先,我修饰了 DBContext 以加载配置。你可以跳过这个,如果你有一个,只需添加到你的配置中:
[DbConfigurationType(typeof(MyDbConfiguration))]
public partial class MyContext : DbContext
创建配置类:
public class MyDbConfiguration : DbConfiguration
{
public MyDbConfiguration()
{
this.AddInterceptor(new NVarcharInterceptor()); //add this line to existing config.
}
}
接下来,创建拦截器:
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''", "''");
}
}
关于c# - EF 查询 Oracle 抛出 "ORA-12704: character set mismatch",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34645274/
发现问题 赞比亚的一个项目,主要做主从数据库同步,主库在赞比亚机房,从库在中国青岛阿里云服务器上面,通过Dataguard实现,当运行一段时间后,发现主从数据库的数据不一致了,从库无法启动,报“O
我目前正面临着一堵墙,我正试图从两个不同的表中获取信息,让它们与按计数记录的信息并排显示。一个是第一个表中具有特定值的总金额,第二个是不同列的值。 表A.current与B.id相同 但是我想要的信息
我正在使用数据泵对 4 个 .dmp 文件执行导入并继续接收如下错误集: ORA-39002: invalid operation ORA-39070: Unable to open the log
我的 j2ee Web 应用程序中出现此错误。 java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1 OR
现场测试工程师在半夜电话反馈:在新建的小测试库做XTTS流程验证,遇到错误: ERROR at line 1:
今天有朋友问到如下一则案例,ORA-01114,ORA-27067以及OSD-04026错误同时出现: *** ACTION NAME:() 2009-04-01 09:31:00.762 ***
> set serveroutput on > set autoprint on; > declare > v_first_name empl
IAM在oracle和数据库中真的是全新的。 非常抱歉提出一个愚蠢的问题。 这是我的问题。我有数据库导出(不是我的数据库,所以我不知道它是如何导出的:有区别吗?),我想用以下脚本导入它: @Echo
这些是我尝试从我的 C# 代码执行存储过程时遇到的错误。 ORA-06502: PL/SQL: numeric or value error: character string buffer too
我们有以下 ORA 错误,它以不同的语言打印错误消息。这种情况很少见,我们将不得不重新启动我们的应用程序服务器。在我的分析中,我发现,在连接到数据库时,JDBC 正在通过采用用户的区域设置在内部更改
刚开始时,有一台服务器的ORACLE 11G数据库连接不上,报错:ORA-12541:TNS:无监听程序 重启服务里面的两个Oracle服务,都没解决。 在网上看到一篇文章说另一种可能是oracle
尝试从客户端使用服务名称 orcl 连接到服务器数据库时出现上述错误.当我使用其他服务名称时它正在连接,即 dms 下面是我的 listener.ora SID_LIST_LISTENER = (
我有一个 Java 类,它调用 SQL 过程来执行一些数据库操作。这是我的 Java 方法: public static void buildContent(String id) throws
下面是我的 SQLPLUS 启动、LSNRCTRL SERVICES、LSNRCTRL STATUS 和 TNSPING 的输出。还包括我的 LISTENER.ORA 文件、TNSNAMES.ORA
我尝试通过运行以下sql来生成一些测试数据。 BEGIN FOR i IN 1..8180 LOOP insert into SPEEDTEST select 'column
当我清楚地识别了变量时,Oracle 不断给我一个无效标识符错误。 //get parameters from the request String custID=request.getPa
我必须在我的应用程序中处理 ORA-28011 和 ORA-28002。但是这些 ORA 警告被 JDBC 抑制了(我认为) 我怎样才能在 Java 中捕获这些? 有什么 JDBC 属性吗? 我不喜欢
当我们通过监听器连接到 Oracle 并达到我们的进程限制时,我们得到一个 ORA-12519:TNS:找不到合适的服务处理程序。查看事件的跟踪文件,它显示 ORA-00020:超过最大进程数 (%s
正如标题所说,我正在尝试使用 sed 来替换,例如, ora.LISTENER_SCAN1.lsnr 1 ONLINE ONLINE myserver1 ora.LISTENER_SCAN2.lsnr
我有一个连接到 Oracle 的 Django 应用程序。每刷新 10 次左右,不管是哪个页面,都会报错。重新启动后的第一次 ORA-03113 和每个后续错误 ORA-03135。 我已经检查了数据
我是一名优秀的程序员,十分优秀!