c# - odata unknown function cast -
i have web api project host models, in .net application, when query :
static void titlebyid(moviesservice.container container, short id) { try { moviesservice.title title = container.title.where(w => w.id == id).singleordefault(); if (title != null) { displaytitle(title); } } catch (exception e) { console.writeline(e.message); } }
the problem not query, it's id variable. id variable of short type not int. here exception message :
<?xml version="1.0" encoding="utf-8"?> <m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <m:code /> <m:message xml:lang="en-us">an error has occurred.</m:message> <m:innererror> <m:message>unknown function 'cast'.</m:message> <m:type>system.notimplementedexception</m:type> <m:stacktrace> @ system.web.http.apicontroller.<invokeactionwithexceptionfilters>d__1.movenext()
 --- end of stack trace previous location exception thrown ---
 @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)
 @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task)
 @ system.web.http.dispatcher.httpcontrollerdispatcher.<sendasync>d__0.movenext()</m:stacktrace> </m:innererror> </m:error>
and here odata url :
"get http://localhost:21401/odata/title()?$filter=cast(id,'edm.int32') eq 3&$top=2"
well, type of id property in entites short. how can pass query?
thanks, if have bring more information, please tell me.
i found cast not implemented in filterbinder.bindsinglevaluefunctioncallnode in source code: https://aspnetwebstack.codeplex.com/sourcecontrol/latest#src/system.web.http.odata/odata/query/expressions/filterbinder.cs
one of way solve download code , implement yourself.
Comments
Post a Comment