1

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.

2

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.

1

You're right SPQuery is part of the Server Side API and CamlQuery is part of the Client Object Model.

So if your code is running on a server in the SharePoint Farm you can use SPQuery.

If your code isn't running on one of the servers, then you can use CamlQuery.

0

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 !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.