SPQuery and SPSiteDataQuery in SharePoint

CAML Query in SharePoint can be used with two objects.
SPQuery and SPSiteDataQuery


SPQuery - SPQuery can be used to query a single list.

SPQuery query = new SPQuery();

SPSiteDataQuery - It allows you to query from multiple list wither it can be from a single site or from that site and from sub sites.

SPSiteDataQuery query = new SPSiteDataQuery();

Both SPQuery and SPSiteDataQuery  have Query property which accepts CAML query text.
For SPSiteDataQuery  you may specify scope. SPSiteDataQuery object has a property "Webs"
which defines the scope.

This property is described as "It specifies which web sites to include in the query as specified the scope attribute on the Webs tag in the query. By default, the query considers the current web site."

Like SPQuery you may put Row Limit in SPSiteDataQuery.

Comments

  1. Thanks for this blog. All screenshots can explain the full blogs easily. This is very easy to understand. Using this screen shots know the details becomes easy.
    Informatica Training in Chennai Mylapore

    ReplyDelete

Post a Comment

Popular posts from this blog

CAML Query in SharePoint 2010

Calling REST APi from server side code - C#

All about SharePoint 2010 Content Type Hub

SharePoint Interview Questions and Answers

Calling ASP.Net WebMethod using jQuery AJAX