Exploring Searches

The Searches method of a CMS context enables us to search for assets like channels, postings, template definitions, template galleries, resources, and resource galleries. Uses of the Searches method can be broadly grouped into two main categories: searching for a single asset or searching for a collection of assets. Searching for a collection of assets can be further categorized by the type of asset retrieved: Channel objects, Posting objects, Template objects, or Gallery objects.

Searches automatically take into consideration the rights and privileges of the authenticated context user, the context mode, and multiple versions of an asset (if they exist) when returning assets. However, user subscription settings are not considered when we are searching for channels and postings except for the NewChannels and NewPostings methods. Subscribed channels or postings can be determined by checking the Channel.IsSubscribed property and the Posting.Parent. IsSubscribed property. Be aware, deleted items are never returned from a search.

The results of a search will typically need to be cast as a specific data type in order for the object to be assigned to a variable. The following two lines of code both are equally effective at casting the search result as a posting:

 cmsPosting1 = cmsContext.Searches.GetByGuid(sGuid) as Posting; cmsPosting2 = (Posting)cmsContext.Searches.GetByGuid(sGuid); 

The code in this book typically casts objects using the "as" keyword followed by the data type because it is easier for the code to flow to multiple lines, which is good for displaying code in a limited-width book. Preceding the cast object with the data type in parentheses works just as well in VS.NET.



Microsoft Content Management Server 2002. A Complete Guide
Microsoft Content Management Server 2002: A Complete Guide
ISBN: 0321194446
EAN: 2147483647
Year: 2003
Pages: 298

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net