Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

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 !

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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