我在.NET 4.5 C#,oracle 11g环境中工作。
当我使用datacontext从代码中调用SQL语句
时,我遇到了特殊的行为我得到ORA-01722: invalid number
堆栈跟踪:
at Corp.DataServices.ExecuteQueryHandler.HandleQueryException(Exception exception) in c:\dev\CCTech Main\Corp\Corp.Conveyancing.DataServices\FluentData.cs:line 4022
at Corp.DataServices.ExecuteQueryHandler.ExecuteQuery(Boolean useReader, Action action) in c:\dev\CCTech Main\Corp\Corp.Conveyancing.DataServices\FluentData.cs:line 3993
at Corp.DataServices.DbCommand.QueryMany[TEntity,TList](Action`2 customMapper) in c:\dev\CCTech Main\Corp\Corp.Conveyancing.DataServices\FluentData.cs:line 3857
at Corp.DataServices.DbCommand.QueryMany[TEntity](Action`2 customMapper) in c:\dev\CCTech Main\Corp\Corp.Conveyancing.DataServices\FluentData.cs:line 3882
at Corp.Dashboard.Controllers.HomeController.GetInstructionsJson(String id) in c:\dev\CCTech Main\Corp\Corp.Conveyancing.Dashboard\Controllers\HomeController.cs:line 65
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41()
现在到了特殊的部分 当我直接从PL / SQL执行完全相同的sql时,它的工作正常
发生了什么?声明中没有任何演员表。我必须在这里遗漏一些明显的东西。
答案 0 :(得分:1)
您无法以这种方式传递参数。当你这样做时,它会将SQL呈现为:
WHERE productid IN ('1,2,3,4,5')
将尝试将值作为单个字符串强制转换为数字。相反,你可以:
^[0-9][\,0-9]*$