我可以从设置了 ViewFields 的 SPQuery 中检索 SPListItem 的其他字段吗?

发布于 2024-09-07 18:36:51 字数 157 浏览 2 评论 0原文

我正在使用设置了 ViewFields 的 SPQuery 从 SPList 检索 SPListItems。我正在使用 ViewFields 来提高性能。但是,对于某些项目,我需要额外的数据。我知道我可以使用新查询再次检索单个项目。但是,我想知道是否有一种更有效的方法可以让我只提取我需要的附加字段?

I am retrieving SPListItems from SPList with a SPQuery that has ViewFields set. I am using ViewFields to improve performance. However, for some items, I need additional data. I know I can just retrieve the single item again with a new query. However, I am wondering, is there a more efficient way that would allow me to just pull the additional fields I need?

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

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

发布评论

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

评论(1

吾性傲以野 2024-09-14 18:36:51

无法指定您只希望在满足特定条件时包含某个字段。所以您的选择是:

  • 始终获取您需要的所有字段
  • 进行多个查询。在这里,我建议您为不需要 ekstra 字段的项目创建一个,为需要它们的项目创建一个,而不是开始执行每个项目查询
  • 如果您在服务器上,请使用 GetItemById 为您的项目获取完整的 SPListItem特殊项目
  • 创建一个计算字段,如果不满足条件,则该字段为空,否则是 ekstra 字段的串联。您可以在一般查询中包含此字段

There is no way to specify that you only want a field included if certain criteria is meet. So Your options are:

  • Always get all the fields you need
  • Make Multiple queries. Here I'd suggest that you make one for items where you don't need ekstra fields and one for items where you need them instead of starting to do Per Item queries
  • If you're on the server use GetItemById to get full SPListItem's for your special items
  • Make a calculated field which is empty if criteria is not fulfilled and otherwise is a concatenation of your ekstra fields. You can the include this field in your general Query
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文