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.

To know more about CAML Query, please visit my another blog post Learn CAML Query step by Step


Popular posts from this blog

Calling REST APi from server side code - C#

All about SharePoint 2010 Content Type Hub

Calling ASP.Net WebMethod using jQuery AJAX