我可以对WCF数据服务(OData)查询执行“不同"吗? [英] Can I Perform a 'Distinct' with a WCF Data Service (OData) Query?

查看:73
本文介绍了我可以对WCF数据服务(OData)查询执行“不同"吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的需要能够对WCF数据服务查询执行"DISTINCT".

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

据我所知,这种功能不存在.我知道我可以在客户端的Linq查询中使用Distinct扩展方法,但是它仍然可以合并整个结果集(在这种情况下,这不是我想要的).

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).

有什么想法吗?

推荐答案

尚未内置.它目前也不是OData协议的一部分(除count以外没有其他聚合,我们甚至需要考虑).推荐的方法是检索所有数据并在客户端上进行设置操作(糟糕!).

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!).

也就是说,您必须以某种方式在客户端和服务器上都扩展WCF数据服务才能提供此功能(我对它不熟悉,无法将您指向正确的钩子).

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).

您总是可以提供WebMethod(顺便说一下,这只是WCF)来完成这项工作,但是我想那不是您打算使用数据服务的方式.

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.

这篇关于我可以对WCF数据服务(OData)查询执行“不同"吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆