views:

72

answers:

2

I really need to be able to perform a 'DISTINCT' on a WCF Data Service query.

From what I can tell, such a function doesn't exist. I know that I can use the Distinct extension method in the Linq query on the client, but it still hydrates the full result set (which isn't what I want in this particular case).

Any ideas?

+1  A: 

Not built in. It's also not currently part of the OData protocol at all (no aggregation is other than count, which we would definitely need to even consider it). The recommended approach is to retrieve all data and do set operations on the client (yuck!).

That said, you'd have to somehow extend WCF Data Services on both the client and server to provide this functionality (I'm not familiar enough with it to point you to the right hooks).

You could always go with providing a WebMethod (this is just WCF by the way) to do this work, but I would imagine that's not how you intend to use Data Services.

Marc
A: 

I'd recommend using a WCF Data Service, Service Operation - http://msdn.microsoft.com/en-us/library/cc668788.aspx, as a better solution (over a webmethod). Service Operations are a great way to encapsulate query functionality not enabled by the OData query syntax.

Don Demsak