[英]Why SharePoint client object model retrieves all items when query fails?
I'm trying to get the items from a child list (a lookup list i suppose, i'm new in SharePoint development) that are related to their items in the parent list. 我正在尝试从子列表(我想是查找列表,我是SharePoint开发中的新手)中获取与其父列表中的项目相关的项目。 For brevity, lets call them list A for parent and list B for child. 为简便起见,让我们将其称为父级列表A和子级列表B。 So in general, list A has at most 4 to 5 child items from list B, and it can sometimes have no item from B at all. 因此,通常,列表A最多具有列表B的4到5个子项,有时列表B可能根本没有任何项。 I'm using the amazingly useful Camlex.Net library for creating the caml queries. 我正在使用非常有用的Camlex.Net库来创建caml查询。 This is the caml that i'm creating via camlex, very basic: 这是我通过camlex创建的caml,非常基本:
<Query>
<Where>
<Eq>
<FieldRef Name="VisitSummary" LookupId="True" />
<Value Type="Lookup">1</Value>
</Eq>
</Where>
</Query>
The problem is that when item 1 in list A (like in the xml above) doesn't have items in list B, so SharePoint returns all the items in list B, which is not desirable at all. 问题在于,当列表A中的项目1(如上面的xml中的项目)在列表B中没有项目时,SharePoint将返回列表B中的所有项目,这是完全不希望的。 When list A does have child items in B, it works well, it gets only the related items. 当列表A在B中确实有子项时,它运作良好,它仅获取相关项。
Is there a way to tell SharePoint to return some other value, perhaps null or whatever instead of all the items in the child list? 有没有一种方法可以告诉SharePoint返回一些其他值(可能为null或其他值)而不是子列表中的所有项目?
thanks, 谢谢,
ashilon ashilon
You must surrond the query with the <view>
tag. 您必须使用<view>
标记替代查询。
See this question on stackoverflow and this on stackexchange 请参阅关于stackoverflow的问题以及关于stackexchange的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.