0

i want to get back all the documents over a site collection that have the biggest number of likes ? How can I do this writing a caml query? That's what i have tried so far:

SPQuery query = newSPQuery();
Query.query = @ "<where> <Eq> <FieldRef Nom= 'NumberOfLikes'/> <ValueType = 'Integer'> 5 </value> </Eq> </where>" 

This enables me to have the documents that have 5 number of likes but I want those who have the biggest number of likes :s

Thanks for your help

sara
  • 215
  • 1
  • 2
  • 8

2 Answers2

0

The reason why you only get documents which have 5 likes is because you are using the operation . You can use the operator to get the documents whose likes are more than 5.

There are multiple operators that you can use. They are as follows:

Eq                     Equals
===============================================
Neq                    Not equal
Gt                     Greater than
Geq                    Greater than or equal
Lt                     Lower than
Leq                    Lower than or equal too
IsNull                 Is null
BeginsWith             Begins with
Contains               Contains

Let me know if this works for you

lem.mallari
  • 1,274
  • 12
  • 25
0

You can user orderbyquery on NumberOfLikes this way you will get document on maximum like on the top. If you want a limited number of document then you can set a query.rowlimit or if you have nay condition like 5 then you can use as stated all documents gt>5 likes order by likes

agarwal
  • 46
  • 4