What is the difference between CamlQuery and SPQuery
-
09-12-2019 - |
Question
Maybe a simple question, when to use CamlQuery and when to use SPQuery ?
I think that SPQuery is used inside a WebPart running on the SharePoint server, and that CamlQuery is part of the Client Object Model which is used when you connect from a client (CLI, Asp.Net or custom Web Service) to a SharePoint site.
Solution
Yes that's right. CamlQuery is a class in the Microsoft.SharePoint.Client.dll
which is part of the Client Object Model which can be used through a .NET, Silverlight or JavaScript Application.
While SPQuery is part of the Microsoft.SharePoint.dll
which can be used on the Server Side in Farm or Sandbox solutions through Custom C#/.NET code.
OTHER TIPS
While using CAMLQuery in COB -> make sure you enclose your query with and ofcourse the closure tag - as this is not SPQuery.Query
In CAMLQuery its ViewXML -> not a Query !
my 1 cent !