Tuesday, 8 May 2012

SharePoint 2010 SPQuery, SPSiteDataQuery and CrossListQueryInfo


  • SPQuery Class
  • SPSiteDataQuery Class
  • CrossListQueryInfo* Class
 

SPQuery Class used for query a data from a specific list and also used for join two lists.

SPSiteDataQuery: this class used for cross site query. Query a data within site collection or specific web.

Microsoft Definition:
You can use an instance of this class to retrieve data from selected lists or from all lists in the current site collection. Specify the scope of the query by setting the Webs property. Specify the lists to participate in the query by setting the Lists property and the fields to return by setting the ViewFields property. Control data selection and order by setting the Query property.

CrossListQueryInfo* (SharePoint Server) : This class only available in SharePoint Enterprise addition. For this you have to include Microsoft.SharePoint.Publishing namespace. 

Microsoft Definition:
The CrossListQueryInfo object uses the CrossListQueryInfo object to get the cached results or, if there are no cached results available, it performs a cross-list query to the database and then caches the results for future use.Audience targeting is then applied to the result set, depending on the setting specified in the CrossListQueryInfo object. You can use the CbqQueryCacheobject to obtain a CrossListQueryInfo object for a specific Content by Query Web Part. 

Code Snippet
  
 CAML Query for SPSiteDataQuery and  CrossListQueryInfo are the same.

Both SPSiteDataQuery and CrossListQueryInfo has a following  attributes  to get the results.

  1. Lists: Lists attribute is a type of string. It takes CAML query. That Query contains
    • Base type
    • Sever Template
    • One more specifics List Ids.
  2. Webs: Webs attribute is a type of string. It takes CAML query as string. The query contains
    • Current.web (if not specified)
    • Current.web (if not specified)
    • Site collection – all web and site collection
    • Recursive – Current web and all child webs  
http://sharepointfordeveloper.blogspot.in/2012/04/sharepoint-2010-spquery-spsitedataquery.html


    string lists = "<Lists BaseType=\"5\" />";
    string viewFields = "<FieldRef Name=\"Title\" />";
    string webs = "<Webs Scope=\"SiteCollection\" />";
    SPSiteDataQuery siteQuery = new SPSiteDataQuery();
    siteQuery.Lists = lists;
    siteQuery.ViewFields = viewFields;
    siteQuery.Webs = webs;
    results = SPContext.Current.Web.GetSiteData(siteQuery);


This query returns the title of all items in Issue lists in all sites in the current site collection. Nothing special here. This method of crawling for content works in both WSS and in MOSS. If you are running Microsoft Office SharePoint Servers, you can also use the CrossListQueryInfo object to query for content. The advantage is that SharePoint has a caching mechanism for the queries that you run. By
using CrossListQueryInfo, your webpart will use this caching mechanism. And you can also make use of audience targeting. See this link for more info.


=============

PortalSiteMapProvider

Deploying a Visual Web Part to your Remote-Hosted Fpweb.net SharePoint Site using Visual Studio 11 (Dev Preview)

Difference between SharePoint 2010 and MOSS 2007

Monday, 7 May 2012

how to use delegate controls in Sharepoint 2010



http://www.helpmeonsharepoint.com/2012/04/sharepoint-delegate-controls.html

http://howtosharepoint.blogspot.in/2010/04/how-to-use-delegate-controls-in.html

http://www.fivenumber.com/understanding-sharepoint-delegate-control/
http://www.spdavid.com/post/2010/01/21/GlobalNavigation-Delegate-Control-in-SharePoint-2010.aspx


SharePoint has a couple of delegate controls like
AdditionalPageHead
GlobalSiteLink0
GlobalSiteLink1
GlobalSiteLink2
PublishingConsole
QuickLaunchDataSource
SmallSearchInputBox
TopNavigationDataSource

What is the use of delegate control?
Using the delegate control a developer can customize the SharePoint site controls without editing or even touching the master page.
Note: We are not customizing the existing (default) delegate control but we are creating our own control loading onto the SharePoint site.

SharePoint Application Pages Vs Site Pages

http://akifkamalsyed.wordpress.com/2010/06/12/sharepoint-application-pages-vs-site-pages/


Site pages support page customization through the browser and with SharePoint Designer 2010. Examples of site pages include the home page (default.aspx) for a site, as well as the pages associated with lists and document libraries, such as AllItems.aspx, NewForm.aspx, and EditForm.aspx.

The downside to site pages is that they require an elaborate processing infrastructure that has implications on security, performance, and scalability.

Customized site pages run in safe mode and, consequently, do not support inline code. To process the request for a customized site page, SharePoint Foundation must retrieve the 
content of pages from across the network in the content database. SharePoint Foundation must also parse each customized site page individually, as well as execute it in a special no-compile mode.

Since each customized page instance must be loaded separately into memory, it will affect the performace of large server farm.

Application pages do not support customization, which gives them a few distinct advantages over site pages.
Advantages:
- Application pages are not tracked in the content database.
- They never run in safe mode and they can contain inline code.
- Each application page is always compiled into a single assembly DLL so that it performs and scales better than site pages that can be customized.
- Since application pages must be deployed inside the SharePoint Root directory, they cannot be used within sandboxed solutions. If you are required to build a SharePoint solution that targets the sandbox, the only type of page that you can add to a site is a site page.

What is the difference between Site Definition and Site template?

To create or use site definition you need server admin access, but site template can install from web UI by site owners. 
2. Site definition supports feature stapling, but for site template additional features must be activated in gallery. 
3. Site definitions are stored in hard disk, but site templates are stored in content DB. 
4. Site definition can provision multiple webs, but site templates for single web only. 
5. Creating site definition is relatively complex then site template creation.



  • Site Definition Files are on disk, better performance.
  • Site Template Files are in database, less efficient.

Site definition (Advantages):

  • Data is stored directly on the Web servers, so performance is typically better.
  • A higher level of list customization is possible through direct editing of a Schema.xml file.
  • Certain kinds of customization to sites or lists require use of site definitions, such as introducing new file types, defining view styles, or modifying the Edit menu.


Site definition (Disadvantages):

  • Customization of site definition requires more effort than creating custom templates.
  • Editing a site definition after it has been deployed is difficult.
  • Doing anything other than adding code can break existing sites.
  • Users cannot apply a SharePoint theme through a site definition.
  • Users cannot create two lists of the same type with different default content.
  • Customizing site definitions requires access to the file system of the front-end Web server.


Site Templates (Advantages):

  • Custom templates are easy to create.
  • Almost anything that can be done in the user interface can be preserved in the template.
  • Custom templates can be modified without affecting existing sites that have been created from the templates.
  • Custom templates are easy to deploy.


Site Templates (Disadvantages):

  • Custom templates are not created in a development environment.
  • Custom templates are less efficient in large-scale environments.
  • If the site definition on which the custom template is based does not exist on the front-end server or servers, the custom template does not work.

Saturday, 5 May 2012

SharePoint farm


A SharePoint farm is a collection of SharePoint servers or SQL servers that work in concert to provide a set of basic SharePoint services that support a single site. 
The ability of multiple servers to work in conjunction and provide redundancy is important in the cloud, especially for large data centers. One value of such a system is its failovercapabilities -- if any server is incapacitated, another one can take over for it. The servers can also provide readily available backups that can scale to immense sizes.