ashilon
ashilon

Reputation: 1951

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. For brevity, lets call them list A for parent and list B for child. 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. I'm using the amazingly useful Camlex.Net library for creating the caml queries. This is the caml that i'm creating via camlex, very basic:

<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. When list A does have child items in B, it works well, it gets only the related items.
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?

thanks,
ashilon

Upvotes: 0

Views: 86

Answers (1)

Max
Max

Reputation: 7100

You must surrond the query with the <view> tag.

See this question on stackoverflow and this on stackexchange

Upvotes: 1

Related Questions