Is it possible to use this code in OData?
IQueryable<CallLogInfo> CallLogInfos = _callCenterServiceAccessor.CallLogInfos.Where(x => x.LogId == logid);
var log = CallLogInfos.ToList();
return log.Any();
I checked my request that it generated and I saw this:
http://services/CallCenter/CallCenterDataService.svc/CallLogInfos(1364974501.4)
so get this error:
<m:message xml:lang="en-US">Resource not found for the segment 'CallLogInfo'.</m:message>
but when I manually make a request to this request url:
http://services/CallCenter/CallCenterDataService.svc/CallLogInfos
Its ok.
As far as I know a request like your code should be possible.
Assuming that LogId is the Key column of you OData Service, your code
CallLogInfos.Where(x => x.LogId == logid);
will be transformed internally by the OData Service to
http://services/CallCenter/CallCenterDataService.svc/CallLogInfos(logid)
which is the standard syntax to get an element with a specific Id.
The error message you showed is thrown, if a query for an Id does not find an entry in the list, have you checked if the Id you provide is correct?
(If that is the problem, you can turn off this behavior by setting the IgnoreResourceNotFoundException Property of the service context (see MSDN))
In a test that I made, a query like yours does work, maybe your Odata service implementation contains errors?
You can try your code and your service with a tool like LinqPad which is helpful to try out things like that.