views:

342

answers:

1

I'm trying to create a CAML query for a list in SP.

I thought of using the Modify view pages to create a basic view including a filter, then use some code to examine the Query Prop of the SPView:

string t = dataList.Views["MyView"].Query;

But CAML in t does not contain any Where elements. Just the orderby

<OrderBy>
    <FieldRef Name="ID" />
</OrderBy>

How does SharePoint store the CAML for view filters?

+1  A: 

Weird.

Because if you examine built in list schema (for example tasks list schema you can find at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\TasksList\Tasks\schema.xml) there is Where clause in Query element:

<View>
*....*
    <Query>
      <OrderBy>
        <FieldRef Name="Modified" Ascending="FALSE">
        </FieldRef>
      </OrderBy>
      <Where>
        <Or>
          <Neq>
            <FieldRef Name="Status">
            </FieldRef>
            <Value Type="Text">$Resources:core,Tasks_Completed</Value>
          </Neq>
          <IsNull>
            <FieldRef Name="Status">
            </FieldRef>
          </IsNull>
        </Or>
      </Where>
    </Query>
  </View>

Oh, you may try SPCamlViewer to examine your views.

Janis Veinbergs