IGrouping 的实现类是什么?
我正在尝试创建一个 WCF 数据服务 ServiceOperation,它在服务器端进行分组,然后将数据发送到客户端。
当我尝试调用它(甚至连接到该服务)时,我收到错误。它说它无法构造接口。
我使用的唯一界面是 IGrouping。
该接口的实际类是什么?
更新:
我在调试示例应用程序时检查了类型,它告诉我它是:
System.Linq.Lookup<TKey,TElement>.Grouping
但是它在哪个程序集中?
I am trying create a WCF Data Services ServiceOperation that does grouping on the server side and then sends the data down to the client.
When I try to call it (or even connect to the service) I get an error. It says that it can't construct an interface.
The only interface I am using is IGrouping.
What is a/the actual class for this interface?
Update:
I checked the type while debugging a sample app and it told me it was:
System.Linq.Lookup<TKey,TElement>.Grouping
But what assembly is it in?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
BCL 中的多种类型实现了
IGrouping
,但是它们都是内部的,除了通过IGrouping
接口之外无法访问。但
IGrouping
只是一个具有关联键的IEnumerable
。您可以轻松实现由List
支持的IGrouping
,并且跨调用边界序列化应该不难:应用
GroupBy< /code> 运算符,您可以创建
Grouping
实例列表:Several types in the BCL implement
IGrouping
, however they are all internal and cannot be accessed except by theIGrouping
interface.But an
IGrouping
is merely anIEnumerable<TElement>
with an associated key. You can easily implement anIGrouping
that is backed by aList<TElement>
and that should not be hard to serialize across a call boundary:After applying the
GroupBy
operator you can create a list ofGrouping
instances:这可能是 IGrouping 最基本、最通用的实现。它的构造函数采用一个键和一组值。
Here is probably the most basic and generic implementation of IGrouping. Its constructor takes a key and a set of values.
它是嵌套在 System.Linq.Lookup中的类型;
System.Core
程序集的内部。输出:
从 .NET 4.0 开始,核心 .NET 框架中没有实现 System.Linq.IGrouping的公共类型。如果您需要这样一种类型(假设它是可序列化的),那么不幸的是,您可能必须自己滚动一个类型。
It's a type nested in
System.Linq.Lookup<TKey,TElement>
; internal to theSystem.Core
assembly.Output:
As of .NET 4.0, there is no public type in the core .NET framework that implements
System.Linq.IGrouping<TKey,TElement>
. If you need such a type (say that's serializable), you'll probably have to roll one yourself, unfortunately.