Wednesday, December 30, 2009

How to Display CAML Query Generated by LINQ to SharePoint Providers

When we write LINQ to SharePoint Query basically this query will be converted to CAML Query by SPLINQ Providers. Here i am going to show  when we execute the LINQ To SharePoint query  how to get Equivalent of CAML Query for LINQ query.

CAML – Collaborative Application Markup Language.

image

CAML Query

image

LINQ Query

image

EQ  CAML Query

<View><Query><Where><BeginsWith><FieldRef Name="ContentTypeId" /><ValueType="ContentTypeId">0x0100</Value>
</BeginsWith></Where></Query>
<ViewFields><FieldRef Name="Fname" /><FieldRef Name="Lname" /><FieldRef Name="Email" /><FieldRef Name="Phone" />
<FieldRef Name="ID" />
<FieldRef Name="owshiddenversion" /><FieldRef Name="FileDirRef" /><FieldRef Name="Title" />
</ViewFields><RowLimit Paged="TRUE">2147483647</RowLimit>
</View>

LINQ Query

image

EQ CAML Query

<View><Query><Where><And><BeginsWith><FieldRef Name="ContentTypeId" /><Value Type="ContentTypeId">0x0100</Value></BeginsWith><Eq><FieldRef Name="Title" /><Value Type="Text">Manager</Value></Eq></And></Where></Query><ViewFields><FieldRef Name=
"Fname" /><FieldRef Name="Lname" /><FieldRef Name="Email" /><FieldRef Name="Phone" /><FieldRef Name="ID" /><FieldRef Name="owshiddenversion" /><FieldRef Name="FileDirRef" /><FieldRef Name="Title" /></ViewFields><RowLimit Paged="TRUE">21474836
47</RowLimit></View>

Result


Manager Chaz  P  2323232322
Manager Jaycy  Shuchi  232322222222
Manager Ganesh  S  3333333333
Press any key to continue . . .

This is one-way to get/Generate  CAML query.[ without pain we can gain here]  :)

Nandri (Thanks)

SreenivasaRagavan.

No comments: