开发者

Can I Perform a 'Distinct' with a WCF Data Service (OData) Query?

I really need to be abl开发者_JAVA技巧e 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜