2

I am using WCF Data Services and RavenDB.

Everything seemed to work very nicely until I came up with one thing: querying by ID.

Either this way:

/DataService.svc/EntitySet?$filter=ID eq '123'

Or:

/DataService.svc/EntitySet('123')

When I try to make a call to either of these urls, I get this:

Attempt to query by id only is blocked, you should use call session.Load("123");
instead of session.Query().Where(x=>x.Id == "123");
You can turn this error off by specifying
documentStore.Conventions.AllowQueriesOnId = true;
but that is not recommend and provided for backward compatibility reasons only.

How can I interrupt WCF Data Service to make a custom call to database instead of a default one with session.Query()?

As far as I know, Query interceptors will not work, because they need to have a particular EntitySet defined.

Dovydas Navickas
  • 3,533
  • 1
  • 32
  • 48
  • I don't have a good answer for you. You can do as the error suggests and change the convention, but it does have performance impact. If this was WebAPI, I'd suggest a separate route for loading than querying, but not sure if this is possible in WCF Data Services. Personally, I have given up on OData all together after reading [this](http://stackoverflow.com/a/9579090/634824). Sorry I can't offer a direct solution. Perhaps someone else can. – Matt Johnson-Pint Jul 23 '13 at 22:32
  • It is possible to create a new route by using Service Operations, but I am using JayData as a JavaScript OData framework and would not like to change their source, to use my service operation, instead of default one.. – Dovydas Navickas Jul 24 '13 at 08:17

0 Answers0