Calm is a .NET library developed in C# that allows you to build (SharePoint SPQuery) queries cleaner than if you do it by hand. Calm makes it easier for SharePoint developers to build (SPQuery) queries in a more expressive and type-safe manner avoiding the need of having to concatenate strings to get it done.

Using Calm

By using this library you can convert the following string:

            <FieldRef Name="ContentType" />
            <Value Type="Text">My Content Type</Value>
            <FieldRef Name="Description" />
   <GroupBy Collapse="TRUE">
      <FieldRef Ascending="FALSE" Name="Title" />
      <FieldRef Name="_Author" />
      <FieldRef Name="AuthoringDate" />
      <FieldRef Ascending="TRUE" Name="AssignedTo" />

into the following C# code:
var query = new Query()
    Where = new Where(
        new Or(
            new Eq<string>(fieldName: "ContentType", value: "My Content Type", type: SPFieldType.Text),
            new IsNotNull(fieldName: "Description"))),

    GroupBy = new GroupBy(fieldName: "Title", collapsed: true),
    OrderBy = new OrderBy(fieldName: "_Author").ThenBy(fieldName: "AuthoringDate").ThenBy(fieldName: "AssignedTo")

var spQuery = new SPQuery();
spQuery.Query = query.ToString();

Last edited Mar 28, 2012 at 2:53 PM by gentilem, version 19