Karine bosch andy-van_steenbergen-caml-spsbe12

Post on 05-Dec-2014

735 views 0 download

description

When LINQ was introduced into SharePoint 2010 it seamed like the way to go. But more and more we see that LINQ can have a performance impact. Now we see that CAML gains on importance again but it remains an exotic language that not everybody wants to learn. Therefore tools like the new CAML Designer can come in handy.

transcript

Andy Van Steenbergen

Karine BoschSharePoint MVP

CAML is NOT dead!

A big thanks to our sponsorsPlatinum Sponsors

Gold Premium Sponsors

Gold Sponsors

Venue Sponsor

About Us• Karine Bosch

• SharePoint MVP since 2009

• Technical assistent of Patrick Tisseghem till September 2008

• Developer of the U2U CAML Builder

• Technical Lead SharePoint Competence Center @ ING

• Andy Van Steenbergen

• SharePoint consultant @ Ordina

• Vice-president BIWUG

Agenda

• What is CAML?

• CAML Basics

• CAML Deep Dive

• The new CAML Designer

What is CAML?• Collaborative Application Markup Language

• XML-based query language

• Introduced in SharePoint 2001

• SharePoint 2010: LINQ to SharePoint

The Basics• Ordery By

• Where

• ViewFields

• Query options

Order By Clause• To sort list items

• In ascending order

• In descending order

• On more than 1 field

<OrderBy> <FieldRef Name=“Title” /></OrderBy>

<OrderBy> <FieldRef Name=“Title” Ascending=“False” /></OrderBy>

<OrderBy> <FieldRef Name=“Title” /> <FieldRef Name=“LastName” Ascending=“False”/></OrderBy>

Where Clause• Operators

• IsNull - IsNotNull

• Eq – Neq

• Geq – Gt – Leq – Lt

• BeginsWith

• Contains

• Includes

• In

• Example of a simple syntax:

<Where> <Eq> <FieldRef Name=“LastName” />

<Value Type=“Text”>Van Steenbergen</Value> </Eq></Where>

Where Clause• More than one criterium

• Nested XML

• And / Or operators

• Example of a nested syntax

<Where> <Or> <Eq> <FieldRef Name=“LastName” />

<Value Type=“Text”>Van Steenbergen</Value> </Eq>

<Eq> <FieldRef Name=“LastName” />

<Value Type=“Text”>Bosch</Value> </Eq> </Or></Where>

Where Clause• Example of a complex syntax

<Where> <Or> <Or> <Eq> <FieldRef Name=“LastName” />

<Value Type=“Text”>Van Steenbergen</Value> </Eq>

<Eq> <FieldRef Name=“LastName” />

<Value Type=“Text”>Bosch</Value> </Eq> </Or> <Gt> <FieldRef Name=“DownloadStart” />

<Value Type=“DateTime”>2012-04-28T00:00:00Z</Value> </Gt> </Or></Where>

Where Clause for DateTime fields• DateTime Fields

• Query on date only

• Query on date and time value

<Where> <Gt> <FieldRef Name=“DownloadStart” />

<Value Type=“DateTime”>2012-04-28T00:00:00Z</Value> </Gt></Where>

<Where> <Gt> <FieldRef Name=“DownloadStart” IncludeTimeValue=“True”/>

<Value Type=“DateTime”>2012-04-28T00:00:00Z</Value> </Gt></Where>

Where Clause for Lookup fields• Lookup fields

• Query on lookup value

• Query on ID

<Where> <Eq> <FieldRef Name=“Country” />

<Value Type=“Lookup”>Belgie</Value> </Eq></Where>

<Where> <Eq> <FieldRef Name=“Country” LookupId=‘True’/>

<Value Type=“Integer”>15</Value> </Eq></Where>

ViewFields Clause• Restrict the number of fields returned

• No ViewFields clause

• Fields of default view are returned

<ViewFields> <FieldRef Name=“LastName” /> <FieldRef Name=“FirstName” /></ViewFields>

Query Options • RowLimit

• IncludeMandatoryColumns

• DatesInUtc

• ExpandUserField

• Files and folder options

Query Options and the SharePoint Object Models

• Since SharePoint 2003• Server Object Model

• Lists.asmx web Service

• Since SharePoint 2010• .NET Client Object Model

• Silverlight Client Object Model

• JavaScript Client Object Model

QUERY OPTIONS

Query Options – Files and Folder options

• Where

• FSObjType

• 0 = Files

• 1 = Folders

• ViewAttributes• Scope

• RecursiveAll

• Recursive

• FilesOnly

• Folder

QUERY OPTIONS – FILES AND FOLDERS

Advanced CAML – New elements • New CAML elements

• Includes - NotIncludes

• In

<Where> <In> <FieldRef Name='Title' /> <Values> <Value Type='Text'>Test 1</Value> <Value Type='Text'>Test 2</Value> </Values> </In></Where>

<Where> <Includes> <FieldRef Name=‘City' /> <Value Type='LookupMulti'>Antwerp</Value> </Includes></Where>

Advanced CAML (vNext)

• New in CAML

• Taxonomy Fields

• Calendar Lists

• DateRangesOverlap

• SiteDataQuery

CAML Designer vNext

• Related Lists (caml)

• Content Type Designer