Saturday, August 6, 2011

Camlex.Net 2.4 is released

Today I released Camlex.Net 2.4 version. The following functionality was added:

  • Querying by user id (DataType.UserId):
   1: string caml = Camlex.Query().Where(x => x["Author"] ==
   2:     (DataTypes.UserId)"123").ToString();

will produce the following CAML:

   1: <Where>
   2:   <Eq>
   3:     <FieldRef Name="Author" LookupId="True" />
   4:     <Value Type="User">123</Value>
   5:   </Eq>
   6: </Where>
Note on the LookupId=”True” attribute. It indicates Sharepoint that you want to query using integer user id – not by user name.

Querying by user names is still supported of course. It works like in previous versions – you need to cast rvalue to (DataTypes.User):

   1: string caml = Camlex.Query().Where(x => x["Author"] ==
   2:     (DataTypes.User)"Firstname Lastname").ToString();

and you will get the following CAML:

   1: <Where>
   2:   <Eq>
   3:     <FieldRef Name="Author" />
   4:     <Value Type="User">Firstname Lastname</Value>
   5:   </Eq>
   6: </Where>
  • Querying by current user’s id:
   1: string caml = Camlex.Query().Where(x => x["Author"] ==
   2:     (DataTypes.Integer)Camlex.UserID).ToString();

will create a query for retrieving items which has Author field equal to current user:

   1: <Where>
   2:   <Eq>
   3:     <FieldRef Name="Author" />
   4:     <Value Type="Integer">
   5:       <UserID />
   6:     </Value>
   7:   </Eq>
   8: </Where>

Like many other features this release was initiated by feedback which we receive from Sharepoint developers who use Camlex.Net in their work. If you think that some feature will be useful for Camlex, don’t hesitate to discuss it on the Camlex discussions section on the Codeplex.

1 comment: