Sunday, November 18, 2012

Camlex.Client 1.1 is released

In this weekend we (I and Stef Heyenrath who joined the project some time ago) released Camlex for Client object model v.1.1. In this release support of RowLimit was added. In Client OM this tag is similar SPQuery.RowLimit property of basic Sharepoint object model, i.e. it allows to limit number of rows returned from the query. In CamlQuery class which is used in the client version, there is no separate property for row limit. Instead RowLimit tag is added with query to the ViewXml property. So it was quite natural to extend IQuery interface and add new method Take(int rowLimit) in it. So it will act as standard Take() method in Linq. Here is example:

   1: var camlQuery = Camlex.Query()
   2:     .Where(x => (string)x["Title"] == "test")
   3:     .Take(5)
   4:     .ToCamlQuery();

will produce the following CAML:

   1: <View>
   2:     <Query>
   3:         <Where>
   4:             <Eq>
   5:                 <FieldRef Name=\"Title\" />
   6:                 <Value Type=\"Text\">test</Value>
   7:             </Eq>
   8:         </Where>
   9:     </Query>
  10:     <RowLimit>5</RowLimit>
  11: </View>

The idea of adding Take() method came from Stef, so all credits go to him. I helped with technical implementation only. New version is already on codeplex and in Nuget gallery.

No comments:

Post a Comment