Question

I have a base entity, and a derived entity, with an extra boolean property. My WCF Data Service exposes an EntitySet of the base entity. I can query it in a browser:

http://myserver/myservice/BaseSet/Namespace.Derived()?$filter=(BoolProp eq false)

And I get a collection of objects of my Derived type. All good.

In my client I have a grid which takes a DataServiceQuery. So I constructed my query:

var query = context.CreateQuery<Proxy.Derived>("BaseSet");

But when I try to filter on derived properties it returns an error. And when I examined the URL it used in its request it's missing the chunk for my derived type, i.e. it looked like:

http://myserver/myservice/BaseSet()?filter=(BoolProp eq false)

What's the proper way to construct a DataServiceQuery that I can use to query using properties on my derived type?

Was it helpful?

Solution

Turns out all I needed was to extend the entitySetName argument to include my derived type:

var query = context.CreateQuery<Proxy.Derived>("BaseSet/Namespace.Derived")();

The name of the argument isn't great. Now I actually bother to read the documentation it does tell me that the entitySetName should be "A string that resolves to a URI." Not sure that helps most people but I should have checked it sooner.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top