Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

odata unknown function cast

$
0
0

I have a web api project that host my models, in my .net application, when I query this :

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 is not with the query, it's from id variable. the id variable is of the short type not an int. here is the 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>   at System.Web.Http.ApiController.&lt;InvokeActionWithExceptionFilters&gt;d__1.MoveNext()&#xD;---End of stack trace from previous location where exception was thrown ---&#xD;
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&#xD;
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;
   at System.Web.Http.Dispatcher.HttpControllerDispatcher.&lt;SendAsync&gt;d__0.MoveNext()</m:stacktrace></m:innererror></m:error>

and here is odata url :

"GET http://localhost:21401/odata/Title()?$filter=cast(Id,'Edm.Int32') eq 3&$top=2"

well, the type of Id property in my entites is short. how can I pass it to the query?

Thanks, If I have to bring more information, please tell me.


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>