Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET 4.5
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Amazon Web Services
Analysis Services
Android
Architecture
Arduino
ASP .NET Web API
ASP.NET
ASP.NET MVC
ASP.NET WebForms
Azure
B2B (Business Integration)
BDD
Big Data
Bing
BizTalk
Book Excerpts
Build and Deploy
Business Intelligence
C#
C++
ClickOnce
Cloud Computing
Code Contracts
CODE Framework Info - non Technical
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Debugger
Design Patterns
Development Process
Display Technologies
Distributed Computing
Document Database
DotNetNuke
DSL
Dynamic Languages
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Git
Graphics
HTML 5
Internet Explorer 8.0
Interviews
IOS
iPhone
Iron Ruby
Java
Java Script
JavaScript
jQuery
JSON
Lightswitch
LINQ
Linux
LUA
Mac OS X
MDX
Messaging
Metro
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Dynamics
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
MsBuild
MVVM
MySQL
Network
NHibernate
node.js
NOSQL
Nuget
Object Oriented Development
Objective C
Odata
OLAP
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
PHP
Podcasts
Post Mortem
PowerPoint
Print/Output
Prism
Product News
Product Reviews
Project Management
Prolog
Python
Q&A
Rails
Rake
Razor
Reporting Services
REST
RIA Services
Ruby
Ruby on Rails
Scheme
Search
Security
Services
SharePoint
SignalR
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server 2012
SQL Server CE/AnyWhere/Mobile/Compact
SSIS
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
TFS
Tips
TypeScript
UI Design
UML
User Groups
VB Script
VB.NET
Version Control
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 11
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio 2011
Visual Studio 2012
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WebMatrix
WF
Whitepapers
Windows 7
Windows 8
Windows Azure
Windows Live
Windows Phone 7
Windows Phone SDK
Windows Server
Windows Vista
WinForms
WinRT
Workflow
WPF
XAML
Xiine Documentation
XML
XNA
XSLT



LearnNow


XAMALOT
 


SSWUG

Reader rating:
Click here to read 2 comments about this article.
Article source: CoDe (2008 May/Jun)


Article Pages:  1  2 - Next >


SharePoint Applied: CAML, Your New Pet

SharePoint is a very powerful platform. It gives you a very easy-to-setup place to put your data in. And you know what happens when you have a tool like SharePoint? People use it! And then when people have been putting in data, they want to retrieve it, in all sorts of weird ways. Putting in data is only half the story, and I’d argue the easier part. It is fetching the data in a meaningful and targeted manner that separates the wheat from chaff.

Business users can be amazing. They like to hit us with scenarios we could not have imagined in our wildest dreams when we thought we had all requirements figured out. Much to my chagrin, I have heard the following, “Oh yeah, that is a new requirement!”

It is thus important that the tools developers use allow them the agility and flexibility to satisfy such needs and changing requirements.

At the very heart of it, every system is basically data in and data out. Sure, standard adages apply, good architecture, garbage in, garbage out, etc. But SharePoint builds upon the experience of many years, and thus puts in place a number of things that you, the developer otherwise would have had to worry about. For instance, every piece of content that goes into SharePoint tracks who put it there, when, who edited it last, and when they edited it. Also, a few clicks away are things such as versioning, approve content etc. But in addition to such tracking information, sometimes, you need to fetch data out of a SharePoint installation that may or may not be so straightforward.

Retrieving Data Out of SharePoint

You can choose from many ways to pull data out of SharePoint. You can use the object model and get a hold of the SPList object, and run a for/each over SPListItems. Of course, that isn’t the smartest way to filter for data though. Filtering via iteration can be extremely resource expensive.

You could use search, even programmatically. You can do so by using the FullTextSqlQuery object as demonstrated in the following article at http://blah.winsmarts.com/2008-2-SharePoint_Search_ranking_rules_and_running_it_programatically.aspx. While that will provide you with results quickly, it may or may not provide you with accurate results, and this approach certainly has an external dependency on crawl schedules and algorithms. Given the nature of search, you also have limited control over the sorting mechanisms. The sorting is controlled generally by the rank, which is dependent on an algorithm that you can influence, but not fully control.

And then you have CAML, the Collaborative Application Markup Language. SharePoint uses CAML for many purposes, one of which is extracting the very data you need, and striking an excellent balance between speed, dependability, and accuracy.

Within SharePoint you’ll find a number of objects that use CAML that can help you query for data. In this article, I will look at them one by one.

The Lists Web Service

SharePoint comes with many Web services out of the box. Web services have the innate advantage of isolating atomic pieces of functionality and thus giving you better reliability and flexibility, a concept otherwise known as SOA (service oriented architecture).

Listing 1 shows an easy way to filter out all rows modified by a given user id, using the lists.asmx Web service.

Web services have their advantages, but performance and XmlSerialization isn’t one of them. So it is reasonable to expect that you have very rich support for CAML in the object model as well. At the heart of that you’ll find the SPQuery object.

&

By: Sahil Malik

Sahil Malik is a Microsoft MVP, INETA speaker, a .NET author, consultant, and trainer, and a well-rounded overweight geek. He has a passion for SharePoint, data access, and application architecture.

Sahil loves interacting with fellow geeks in real time. His talks are full of humor and practical nuggets. His talks tend to get very highly charged, fast moving, and highly interactive.

You should check out his blog at http://blah.winsmarts.com

sahilmalik@gmail.com



Listing 1: Using the lists.asmx Web service to execute a CAML query
XmlDocument camlDocument = new XmlDocument();
camlDocument.LoadXml(
    @"<Query>
        <Where>
            <Or>
                <Eq>
                    <FieldRef Name='Author' />
                    <Value Type='User'>
                    MOSS2007\Administrator
                    </Value>
                </Eq>
                <Eq>
                    <FieldRef Name='Editor' />
                    <Value Type='User'>
                    MOSS2007\Administrator
                    </Value>
                </Eq>
            </Or>
        </Where>
    </Query>");


using (moss2007.Lists ws = new moss2007.Lists())
{
    ws.Credentials =
     System.Net.CredentialCache.DefaultCredentials;
    ws.Url = "http://moss2007/_vti_bin/lists.asmx";

    XmlNode xView = 
     camlDocument.CreateNode(
       XmlNodeType.Element, "ViewFields", "");
    XmlNode xQryOpt = 
     camlDocument.CreateNode(
       XmlNodeType.Element, "QueryOptions", "");

    //query the server 
    XmlNode xNode = 
     ws.GetListItems(
       "Announcements", "", 
       camlDocument.ChildNodes[0], xView, 
       "", xQryOpt, "");
}
</div>


Article Pages:  1  2 - Next Page: 'The SPQuery Object' >>

Page 1: SharePoint Applied: CAML, Your New Pet
Page 2: The SPQuery Object

How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
3.5 out of 5

19 people have rated this article.

Instantly Search Terabytes Of Text
“Lightning Fast”
– Redmond Mag
“Covers all data
sources” – eWeek
25+ fielded & full-text search options
dtSearch’s own document filters highlight hits in popular file types
Web Spider supports static & dynamic data
APIs for .NET, Java, C++, SQL, etc.
Win / Linux (64-bit & 32-bit)
www.dtSearch.com
 

      Sharepoint TechCon

 

Sharepoint TechCon