搜索列表以查找与任意字符串列表匹配的关键字
我有一个任意的字符串列表,我想用它来查询我的共享点列表。如果任何字符串出现在列表项“标题”中,我想返回该结果。现在,我知道如何做到这一点的唯一方法是在我的 caml 查询中创建一堆
节点,但是有没有办法做到这一点,这样我就不必动态地为列表中的每个字符串生成一个 OR 节点?与此类似的东西:
<Contains>
<FieldRef Name="Title" />
<Value type="text"> Value1</Value> (OR)
<Value type="text"> Value2</Value> (OR)
<Value type="text"> Value3</Value>
</Contains>
I have an arbitrary list of strings that I would like to query my sharepoint lists with. If any of the strings appear in a list item 'title' I would like to return that result. Right now, the only way I know how to do this is by making a bunch of <OR>
nodes in my caml query, but is there a way to make it so I do not have to dynamically generate an OR node for every one of my strings in the list? something similar to this:
<Contains>
<FieldRef Name="Title" />
<Value type="text"> Value1</Value> (OR)
<Value type="text"> Value2</Value> (OR)
<Value type="text"> Value3</Value>
</Contains>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
LINQ to SharePoint 是您的最佳选择。在 SharePoint 2010 中,您无需使用 LINQ to SharePoint。您的 LINQ 查询将像这样简单:
我必须编写代码来在 CAML 中生成动态 OR 和 AND 节点,以便在 SharePoint 2007/WSS3 中执行相同的操作。使用 U2U CAML builder dll/library 使工作变得更容易。
LINQ to SharePoint is your best option. In SharePoint 2010 you do not need to worry about the underlying CAML by using LINQ to SharePoint. Your LINQ query would be as simple as this:
I had to write code to generate dynamic OR and AND nodes in CAML to do the same thing in SharePoint 2007/WSS3. Using U2U CAML builder dll/library made the job easier though.