Powered by their Codeplex project – Camlex.NET (http://camlex.codeplex.com), Alexey Sadomov and Vladimir Timashkov have released a free online service to convert your CAML Query Strings into c# code.  All you have to do is type in your CAML query and it will spit out the corresponding c# lambda expression you can use in your code.

Example by typing in this CAML Query:

<Query>
  <Where>
    <And>
        <Eq>
            <FieldRef Name="ID" />
            <Value Type="Integer">1</Value>
        </Eq>
        <Eq>
            <FieldRef Name="Title" />
            <Value Type="Text">Hello world</Value>
        </Eq>
    </And>
  </Where>
</Query>

You get this code:

Camlex.Query().Where(x => (int)x["ID"] == 1 && (string)x["Title"] == "Hello world") 

The link to the free service is: http://camlex-online.org/

My favorite tool to generate the CAML query itself is still CAML Query Builder by U2U which can be used in both SharePoint 2007 and 2010: http://www.u2u.net/Tools/wincamlquerybuilder/CamlQueryBuilder.aspx

 

Technorati Tags: ,,

Leave a Reply

Your email address will not be published. Required fields are marked *