是什么使得 Select、Join、Where 等方法成为 Linq-to-Object 的标准查询运算符而不是......?

发布于 2024-12-03 10:27:10 字数 302 浏览 0 评论 0原文

1)在内部,是什么使得诸如 SelectJoinWhere 等方法(除了查询表达式被编译器翻译成这些方法调用)是 Linq-to-Object 的标准查询运算符,而不仅仅是碰巧对数据序列进行操作的常规方法?

也就是说,这些运算符提供的所有功能也可以在常规方法中实现,但我们不将这些常规方法称为标准查询运算符?!

2) Linq-to-XML 方法也有同样的问题 - 那么,是什么让它们查询运算符而不仅仅是操作 XML 数据的常规方法?

谢谢

1) Internally, what is it that makes methods such Select, Join, Where etc ( besides the fact that query expressions get translated by compiler into these method calls ) a Linq-to-Object's standard query operators and not just regular methods that happen to operate on sequences of data?

Namelly, all the functionality offered by those operators could also be implemented in regular methods, but we don't call those regular methods standard query operators?!

2) Same question for Linq-to-XML methods – thus, what makes them query operators and not just regular methods that operate on XML data?

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月静好 2024-12-10 10:27:10

它们“只是常规(以及扩展)方法”,但它们也在 LINQ 标准查询运算符 页面:

标准查询运算符是形成语言集成查询 (LINQ) 模式的方法。这些方法大多数都对序列进行操作,其中序列是其类型实现 IEnumerable 接口或 IQueryable 接口的对象。标准查询运算符提供过滤、投影、聚合、排序等查询功能。

一个有趣的问题是 Zip 是否应该计数作为标准查询运算符,因为它是在 .NET 4 中引入的...

Well they are "just regular (well, extension) methods" but they're also defined in the LINQ Standard Query Operators page on MSDN:

The standard query operators are the methods that form the Language-Integrated Query (LINQ) pattern. Most of these methods operate on sequences, where a sequence is an object whose type implements the IEnumerable interface or the IQueryable interface. The standard query operators provide query capabilities including filtering, projection, aggregation, sorting and more.

One interesting question is whether Zip should count as a standard query operator, given that it was introduced in .NET 4...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文