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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With