开发者

Sharepoint 2010 Client Object Model - Large Library - Find item without iteration

I have开发者_运维问答 a large document library (at the moment ~6000 documents) and I need to find a document based on a custom field value (custom column on the library).

Is there a way of getting this document back without iterating through all 6000 documents?

I understand that an iteration must occur at some point, but I would prefer it to happen on the SharePoint server side, rather than transfer them all to the client side then cherry pick the document.

Thanks


You can query Sharepoint. You issue a CAML query which is executed on the server and brings back only items that match the criteria that you specified. You specify the name of the custom column to search on and you specify the value to find. For efficiency , you can ask only for a few fields back (document url for example). So, you do not need to iterate over documents in the list to find the item.

You can find some discussion here: http://msdn.microsoft.com/en-us/library/ee956524.aspx and you can also find examples how to do it from javascript or silvelight.

Example CAML:

        CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml =
        @"<View>
            <Query>
              <Where>
                <Eq>
                  <FieldRef Name='FileLeafRef'/>
                  <Value Type='Text'>Test.docx</Value>
                </Eq>
              </Where>
              <RowLimit>1</RowLimit>
            </Query>
          </View>";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜